int08h / roughenough

A Roughtime secure time sync client and server written in Rust
https://int08h.com/post/roughenough-a-rust-roughtime-server/
Apache License 2.0
123 stars 21 forks source link

Add support for batch-signing requests #3

Closed Aaron1011 closed 6 years ago

Aaron1011 commented 6 years ago

As documented in the Roughtime spec, servers can batch together requests, only signing the root of a computed Merkle tree, in order to increase efficiency.

Following the example of the reference Roughtime implementation, the default batch size is set to 64. However, this value can be changed in the config.

Two pieces of benchmark infrastructure are added - a simple "benchmark mode" on the server, and a "stress test mode" on the client. These features can be used to help pick an optimal batch size for the server.

In "benchmark mode", the server does not log any requests. Instead, it prints out the current request processing speed every second. This helps to keep the output manageable when using the client's "stress test" mode.

In "stress test mode", the client sends the same message to the server in a loop. To prevent accidental flooding of the users's local network, or a remote server, only loopback addresses are supported in this mode.

int08h commented 6 years ago

Awww yessss, I'm excited to look at this @Aaron1011! Give me a day or two to review.

Aaron1011 commented 6 years ago

@int08h: It turns out that my code wasn't actually taking advantage of batching - it was signing the root once per request, rather than once per batch. The latest commit gives a roughly 5x speedup on my machine (~20,000 reqs/s before, ~100,000 reqs/s after).

Aaron1011 commented 6 years ago

@int08h: I've made the changes you requested.

int08h commented 6 years ago

Thank you @Aaron1011!