Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ntcore] Server round robin message processing #7191

Merged
merged 4 commits into from
Oct 11, 2024

Conversation

PeterJohnson
Copy link
Member

@PeterJohnson PeterJohnson commented Oct 11, 2024

Each client has an incoming queue of ClientMessage.

In the read callback:

  • Parse and process only ping messages and a limited number of messages; anything else will get put into the queue and not processed
  • If we queued some messages, we tell the network we stopped reading; this will result in back-pressure if we are reading too slowly. We also start an idle handle to process the queued messages.

In the idle handle callback:

  • For each client, process just a few pending messages. This is performed in round-robin fashion across all clients with pending messages
  • When a client's queue becomes empty, we re-enable the network read
  • When all client queues are empty, we stop the idle handle (so we don't spin)

For local client processing, we use round-robin processing for most cases (including FlushLocal), but still do batch processing of all local changes for explicit network Flush() calls.

Each client has an incoming queue of ClientMessage.

In the read callback:
- Parse and process only ping messages and a limited number of messages;
  anything else will get put into the queue and not processed
- If we queued some messages, we tell the network we stopped reading; this will
  result in back-pressure if we are reading too slowly.  We also start an idle
  handle to process the queued messages.

In the idle handle callback:
- For each client, process just a few pending messages.  This is performed in
  round-robin fashion across all clients with pending messages
- When a client's queue becomes empty, we re-enable the network read
- When all client queues are empty, we stop the idle handle (so we don't spin)
@PeterJohnson PeterJohnson requested a review from a team as a code owner October 11, 2024 22:18
@PeterJohnson PeterJohnson merged commit a621ceb into wpilibsuite:main Oct 11, 2024
36 checks passed
@PeterJohnson PeterJohnson deleted the nt-round-robin branch October 11, 2024 23:26
katzuv pushed a commit to katzuv/allwpilib that referenced this pull request Oct 14, 2024
Each client has an incoming queue of ClientMessage.

In the read callback:
- Parse and process only ping messages and a limited number of messages;
  anything else will get put into the queue and not processed
- If we queued some messages, we tell the network we stopped reading; this will
  result in back-pressure if we are reading too slowly.  We also start an idle
  handle to process the queued messages.

In the idle handle callback:
- For each client, process just a few pending messages.  This is performed in
  round-robin fashion across all clients with pending messages
- When a client's queue becomes empty, we re-enable the network read
- When all client queues are empty, we stop the idle handle (so we don't spin)

For local client processing, we use round-robin processing for most cases (including FlushLocal),
but still do batch processing of all local changes for explicit network Flush() calls.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant