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

VSR/Client: Add vsr.Client.register() #1946

Merged
merged 3 commits into from
May 28, 2024
Merged

Conversation

sentientwaffle
Copy link
Member

@sentientwaffle sentientwaffle commented May 13, 2024

Context

Clients (at the level above vsr.Client) are responsible for automatically coalescing user operations into batches. The maximum batch size is currently message_body_size_max.

In order to minimize replica memory usage when maximum throughput is not needed (e.g. during development), the replica is going to support running with a lower, runtime-defined batch size limit. Since this batch size limit impacts the clients, the replica must communicate it to clients. This will occur via the result of the register request. (Note that this is not implemented in this PR – this PR is a prerequisite.)

Previously, vsr.Client would send its command=request operation=register message when the first of the following occurred:

  1. vsr.Client.request() is called, or
  2. the client receives a pong_client message.

But that means that the first batch created by the client would potentially precede the client actually knowing the batch limit.

Solution

Add vsr.Client.register(callback, user_data). vsr.Client.request() cannot be called until .register() has invoked its callback.

tb_client invoked vsr.Client.register automatically during its setup – no waiting until request()/on_pong(). It will refrain from generating/sending any batches until the register reply arrives.

Future Work (Maybe?)

The above opens up some nice possibilities for UX of the client API:

  • If .register takes too long, we could bubble up an exception/warning to the application suggesting that they might have misconfigured TB (e.g. wrong host/port/cluster_id). (Right now the client just hangs silently forever, which is not a great developer experience.)
  • We could expose .register(), to allow developers to (optionally) wait until the connection is established before they start generating work – since any generated work would just be buffered in memory until register arrives.

Note that CI (replica_test.zig) is failing on this branch. This is semi-unrelated; it is addressed in a separate PR.

# Context

Clients (at the level above `vsr.Client`) are responsible for automatically coalescing user operations into batches. The maximum batch size is currently `message_body_size_max`.

In order to minimize replica memory usage when maximum throughput is not needed (e.g. during development), the replica is going to support running with a lower, _runtime-defined_ batch size limit. Since this batch size limit impacts the clients, the replica must communicate it to clients. This will occur via the result of the `register` request. (Note that this is not implemented in this PR – this PR is a prerequisite.)

Previously, `vsr.Client` would send its `command=request operation=register` message when the first of the following occurred:

  1. `vsr.Client.request()` is called, or
  2. the client receives a `pong_client` message.

But that means that the first batch created by the client would potentially precede the client actually knowing the batch limit.

# Solution

Add `vsr.Client.register(callback, user_data)`. `vsr.Client.request()` cannot be called until `.register()` has invoked its callback.

`tb_client` invoked `vsr.Client.register` automatically during its setup – no waiting until `request()`/`on_pong()`. It will refrain from generating/sending any batches until the register reply arrives.

# Future Work (Maybe?)

The above opens up some nice possibilities for UX:

- If `.register` takes too long, we could bubble up an exception/warning to the application suggesting that they might have misconfigured TB (e.g. wrong host/port/cluster_id). (Right now the client just hangs silently forever, which is not a great developer experience.)
- We could expose `.register()`, to allow developers to (optionally) wait until the connection is established before they start generating work – since any generated work would just be buffered in memory until `register` arrives.
All clients begin to register when the simulation starts.
But if one is partitioned/slow, then it might still be trying to register even after all of the simulator's `requests_max` have been completed.
(Register messages are not counted by `requests_max`.)
@sentientwaffle sentientwaffle force-pushed the dj-vsr-client-register branch from 1c61eba to 068dca6 Compare May 13, 2024 16:05
@@ -30,7 +30,6 @@ pub const Options = union(vsr.ProcessType) {
sum += constants.replicas_max; // Connection.recv_message
// Connection.send_queue:
sum += constants.replicas_max * constants.connection_send_queue_max_client;
sum += 1; // Client.register_inflight
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@sentientwaffle sentientwaffle added this pull request to the merge queue May 28, 2024
Merged via the queue into main with commit a2639cb May 28, 2024
25 checks passed
@sentientwaffle sentientwaffle deleted the dj-vsr-client-register branch May 28, 2024 16:03
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.

2 participants