Guides
Performance tuning
Choose tree depth, leaf bound, memory budget, build settings, serving mode, worker count, connections and deployment shape for StateSync-GKR, with the measured evidence behind each choice and general guidance where no measurement exists.
This guide helps you choose the settings that decide how fast StateSync-GKR runs and how much memory it uses. Each section separates what was measured, and under which conditions, from guidance for the cases the measurements do not cover.
Before you begin#
- Build with
--releasefor the CPU that runs the prover, and use the prepared path described in Prepared execution. The fresh calls compile the circuit and compute its commitment on every call. - For a proof service, start from the reference server or its components in Serving components, which already parallelize witness generation, proving and output per job.
- Read every measured number with its conditions. The results on this page, in Benchmark results and in Serving capacity come from separate experiments, and their ratios do not combine.
What each setting changes#
| Setting | Where you set it | Changes the circuit and proofs | What it trades |
|---|---|---|---|
Tree depth, smt.depth | StateSyncGkrConfig | Yes | Key space against witness, proving and verification work |
Leaf bound, smt.leaf_max_fields | StateSyncGkrConfig | Yes | Payload capacity against the cost of every leaf hash and the depth of the circuit |
Build flags such as -Ctarget-cpu=native | Your build | No | Proving speed on one CPU type against a binary that runs on any x86-64 host |
| Serving mode | --serving-mode of the reference server | No | Reply order against tail latency |
| Worker count | --workers, or your Rayon pool | No | Parallel work against memory for the jobs in flight |
| Jobs in flight | --max-in-flight in continuous mode | No | Parallel work against memory, without batches |
| Batch cap and maximum wait | --batch-max and --max-wait-us in batch modes, or your scheduler | No | Fuller batches against time spent waiting |
| Admission cap | --max-queue | No | How much work waits before further requests are refused |
| Return budget | --return-jobs and --return-bytes | No | Finished replies waiting to be written against server memory |
| Connections | Your clients, or --targets of the load frontend | No | Reply traffic per connection |
| Deployment shape | Your infrastructure | No | Latency and queueing for a given total resource |
A setting that changes the circuit gives it a new commitment and a new circuit identity, so provers and verifiers must change together and existing trees keep their own configuration. The other settings leave proof bytes unchanged, because each proof depends only on its own request.
Tree depth and leaf bound#
What was measured#
Depths 24, 28 and 32 were measured. All nine operation and depth profiles compiled to 118 layers, and the complete encoded proofs grew slowly with depth. Each profile had 768 accepted fixtures, all with the same proof length, which v1.2.0 keeps:
| Operation | Depth 24 (bytes) | Depth 28 (bytes) | Depth 32 (bytes) | Change from 24 to 32 |
|---|---|---|---|---|
| Membership | 176,948 | 181,970 | 182,132 | +2.93% |
| Non-membership | 181,646 | 181,970 | 182,132 | +0.27% |
| Update | 186,992 | 200,762 | 201,086 | +7.54% |
Prepared verification time changed little with depth when the verifier used derived wiring. The table gives the median time of the complete prepared verification call, including request validation and the native hashing of the leaf and its path, on one worker of the 192-core host. Each value is the median of five process medians, each over 300 calls; the verifier is unchanged in v1.2.0:
| Operation | Depth 24 (ms) | Depth 28 (ms) | Depth 32 (ms) |
|---|---|---|---|
| Membership | 5.87 | 6.18 | 5.94 |
| Non-membership | 6.09 | 6.24 | 6.02 |
| Update | 7.24 | 7.98 | 7.56 |
Witness generation, proving and total computation still grow with depth, because the circuit becomes wider.
How to choose#
- Pick the smallest depth whose 2^depth slots cover your key space with room to grow. The default depth, 24, gives about 16.7 million slots.
- Treat the depth and the leaf bound as fixed for the life of a tree. Changing either produces a different circuit, needs new preparations on every prover and verifier, and for the leaf bound can change every leaf digest and root (Configuration).
- Expect to measure for yourself outside the measured range. Depths other than 24, 28 and 32 have no measurements, and the studies did not vary the leaf bound. The leaf pre-image is the bound plus one, rounded up to a multiple of eight field elements, and the leaf hash spends one Poseidon2 permutation per eight elements. Raising the bound past one of those steps therefore adds a permutation to every leaf hash, both in the prover's witness and in the input the verifier rebuilds. Each extra permutation also adds 29 layers to the circuit, which lengthens every proof and adds proving and verification work. The default bound of 31 fills four permutations exactly, so raising it to 32 already adds a fifth. This follows from the circuit layout; the studies did not measure it.
- Before you choose a depth of 31 or more, read the note on key absorption in Configuration.
Build settings#
What was measured#
Proving speed depends on the CPU features the compiler may use. On the 192-core bare-metal host (AMD EPYC 9R45), one prepared depth-24 request on one thread took these median times with v1.2.0:
Build for the CPU that runs the prover.
Prepared depth-24 requests on one thread of the 192-core bare-metal host (AMD EPYC 9R45), v1.2.0, median of 1,000 timed requests in one process per build. On this host the x86-64-v3 build, which uses AVX2, took 0.90 times the time of the native build, which uses AVX-512. Every build produces the same proof bytes.
| Build | Membership (ms) | Non-membership (ms) | Update (ms) | Against native |
|---|---|---|---|---|
Default --release | 28.18 | 30.42 | 42.02 | 1.66–1.71× slower |
-Ctarget-cpu=x86-64-v3 (AVX2) | 15.26 | 16.56 | 22.10 | 0.90× |
-Ctarget-cpu=native (AVX-512) | 16.96 | 18.33 | 24.63 | 1.00× |
Each build ran in one process of 1,000 timed requests. Proof bytes do not depend on CPU-specific code generation: CI compares proof digests from a baseline x86-64 build with those from a native build, as described in Installation.
How to choose#
- Do not run a production prover from the default build when proving speed matters; it was about 1.7 times slower than a native build on this host.
- Build with
-Ctarget-cpu=nativeon the machine type that runs the prover, or name that CPU explicitly. On this AMD host the x86-64-v3 build matched or beat native, so measure both on your own CPU before you choose. - A binary built for one CPU's instruction set needs a CPU that has those instructions. Build per machine type, or keep a baseline build for hosts you have not measured.
Memory#
What was measured#
The production prover uses Libra-style two-phase sparse booking. For a layer with n_in input wires, n_out output wires and m multiplication gates, its auxiliary memory is O(n_out + n_in + m), and it allocates no table over pairs of input wires. Version 1.2.0 keeps this layout and makes 93–94% fewer allocations per proof on the generic circuit of the memory study, with the same requested peak and the same whole-process peak memory.
A separate study on an isolated development host ran the production sparse prover and the engine's own test-only dense reference on generic two-layer circuits under explicit memory limits:
Under a 3 GiB cap, the sparse prover keeps going.
Under a 3 GiB memory limit with swap off, the dense baseline ran out of memory at width 8,192 while the sparse prover returned proofs at every tested width. Peak RAM was measured on v1.1.0; v1.2.0 repeated all 17 attempts with the same outcomes. Width 65,536 is the largest point tested, not a supported maximum.
- Under a 3-GiB cgroup with swap disabled, the sparse prover returned proofs at widths 8,192, 16,384, 32,768 and 65,536, with peak process memory between 36.0 and 259.9 MiB. The dense reference was killed by the out-of-memory mechanism at width 8,192 before it returned a proof. v1.2.0 repeated every attempt with the same outcome.
- At width 2,048, the sparse prover completed 1, 2, 4 and 8 concurrent jobs under a 4-GiB address-space guard, and 4 and 8 concurrent jobs under the 3-GiB cgroup. The dense reference completed 1, 2 and 4 jobs under the address-space guard and 4 under the cgroup, and failed at 8 under both.
- Width 65,536 is the largest width tested, not a supported maximum. The study used generic circuits and does not predict the memory of the sparse-Merkle circuit, and the dense reference is part of StateSync-GKR rather than another GKR implementation.
In serving, server memory stayed bounded under overload: on 192 cores at 5,100 requests/s, with the default return budget of 192 replies and 64 MiB, the server's peak was 535.2 MiB against a 2,760 MiB limit. The confirmation runs at 3,300 requests/s peaked at 335.6 to 338.0 MiB. These peaks are the largest resident memory sampled from /proc; GNU time reported lower peaks for the same processes, 393.5 MiB and 218.5 to 233.4 MiB.
How to choose#
- Budget memory per job in flight. Concurrent jobs share one prepared circuit, but each keeps its own witness, prover state, transcript and proof, so memory grows with the number of jobs running at once.
- In a service, bound the finished replies too. The return budget counts the encoded bytes of replies waiting to be written; jobs in progress, prepared circuits, frames, stacks and socket buffers are outside it, so measure whole-process memory under load as well.
- Measure your own circuit at your depth and concurrency under the memory limit you will deploy with, and keep the failed attempts. An address-space allocation failure and an out-of-memory kill are different outcomes, and a killed process leaves no peak memory to report.
- Share one
PreparedSyncper operation kind instead of cloning it, because a clone copies the compiled circuit.
Serving mode#
What was measured#
At 1,000 requests/s on one 192-core VM, three 60-second runs per mode of the same v1.2.0 binary had p99 33.7–33.9 ms in continuous, 95.6–96.0 ms in batch-fused and 159.2–162.0 ms in original, the earlier serving loop. v1.1.0 measured the same day had p99 433.8–475.1 ms. In continuous mode the p99 stayed at 33 to 34 ms from 100 to 1,150 requests per second.
How to choose#
- Use
continuousunless a client needs replies in batch order; match replies by job identifier. continuoushas no batch cap or batch wait. Its settings are the worker count and the number of jobs in flight.- Use
batch-fusedwhen replies must keep batch order, and size its batch cap as described under Batch cap and maximum wait.
Worker count#
What was measured#
On one 192-core bare-metal host, with two AMD EPYC 9R45 sockets and SMT off, prepared proving-only throughput at depth 24 with batches of 768 grew with the worker count:
Independent proofs scale with the cores you give them.
Prepared proving at depth 24, batch 768, three processes per point on a two-socket bare-metal host. Grey lines are v1.1.0 measured the same day at 1, 48, 96 and 192 workers; v1.2.0 completed 2.41–2.71 times as many proofs per second there, with the same proof bytes in 13,824 comparisons. Worker counts are threads on one machine; witness generation, encoding and transport are excluded.
| Workers | Membership (proofs/s) | Non-membership (proofs/s) | Update (proofs/s) |
|---|---|---|---|
| 1 | 60.70 | 56.15 | 42.40 |
| 8 | 480.80 | 444.39 | 335.82 |
| 48 | 2,798.72 | 2,579.21 | 1,970.26 |
| 96 | 4,956.77 | 4,615.04 | 3,515.38 |
| 192 | 7,713.71 | 7,220.36 | 5,390.07 |
These are v1.2.0 rates, each the median of three processes, and 2.41–2.71 times those of v1.1.0 measured the same day. They are proving-only rates, without witness generation, encoding or transport. The worker counts were thread limits on one large host, so a lower count does not show how a smaller machine would perform. In a probe that kept every thread proving one request after another, each proof took about 1.2 times as long with 192 threads busy as on one thread, which the drop in clock frequency under full load accounts for.
In serving, every confirmed v1.2.0 setting used one worker per core and the default number of jobs in flight: 46 on 48 cores, 94 on 96 cores and 190 on 192 cores. Across the 16 continuous conditions of the 48-core fine study, with 32 to 48 workers and 16 to 46 jobs in flight at 500 and 1,000 requests/s, p99 stayed between 33.3 and 34.0 ms. With v1.1.0 on the same VM at 500 requests/s, 32 workers let the queue grow and accepted-request p99 reached 4.56 to 4.66 seconds.
How to choose#
- In the reference server, set
--workersto the cores and keep the default--max-in-flight. In your own code, size the Rayon pool explicitly and run batches insidepool.install, as described in Batching and parallelism. - Check that memory suffices for that many jobs in flight.
- Measure on the machine size you will deploy. Lowering the thread count on a larger machine does not stand in for a smaller one.
Batch cap and maximum wait#
What was measured#
These settings apply to the batch modes. A fine-grained study on the 48-core VM varied the worker count with batch cap 48, and the batch cap with 48 workers, in 15-second runs repeated three times each. With v1.2.0 in batch-fused mode, every one of 19 conditions accepted every timed request within one second, with mixed-load p99 of 93.1–98.6 ms. The v1.1.0 serving harness reacted strongly to the same settings; its p99 column is over accepted requests:
| Setting, v1.1.0 at 500 requests/s | Accepted-request p99 | Notes |
|---|---|---|
| 32 workers, batch cap 48 | 4,557.771–4,663.165 ms | 15.93–16.83% of requests within one second |
| 36, 40 or 44 workers, batch cap 48 | 266.386–277.384 ms | Every request within one second |
| 48 workers, batch cap 16 | 11,231.230–11,347.565 ms | 847, 912 and 896 explicit refusals in the three runs |
| 48 workers, batch cap 24 | 4,402.638–4,789.998 ms | |
| 48 workers, batch cap 32 | 433.563–474.808 ms | |
| 48 workers, batch cap 40 | 270.028–278.601 ms | |
| 48 workers, batch cap 48 | 262.789–263.385 ms | Three earlier screening runs, the reference for both comparisons |
The refusals at batch cap 16 came from the benchmark server's run limit, which ended runs while jobs were still uncomputed, and they remain in the success denominators. The study also tested maximum waits of 1, 5 and 10 ms, and every confirmed serving setting uses 5 ms. The maximum wait decides when a batch is ready to run; it does not limit how long a ready batch waits behind one that is already running.
How to choose#
- In
batch-fusedmode, start with the batch cap equal to the worker count, as in every confirmed setting, and a short maximum wait. - Small caps leave workers idle and let queues grow. Lower the cap only when measurements show the queue staying flat.
- Tune for the operation mix you expect. With v1.1.0, an update-only load at 500 requests/s did not meet one second in every short run, although the balanced mix did; with v1.2.0 it did in both modes.
- Judge a setting by the fraction of offered requests accepted within your latency budget, the queue trend and memory use, not by accepted requests divided by the offered duration.
Deployment shape#
What was measured#
With the same total worker resources, 96 cores and 192 GiB, and the same frontend, two policies were compared at 1,000 requests/s in three 20-second runs each:
With v1.2.0, both ways of splitting the cores hold the same tail.
Three 20-second runs per policy at 1,000 requests per second with the same total worker resources (96 cores, 192 GiB) and a separate 16-core frontend; bar labels are in milliseconds unless marked. With v1.1.0, two workers with batch cap 48 each accepted every request within 500 ms and one worker with batch cap 96 built a queue. With v1.2.0 in continuous mode both policies accepted every request within 1 s, using 20.8 and 20.5 worker cores. This compares deployment policies, not topology alone.
| Policy | v1.1.0 p99, three runs | v1.1.0 within one second | v1.2.0 p99, three runs |
|---|---|---|---|
| Two 48-core workers | 282.11–329.79 ms | All requests | 33.88–34.13 ms |
| One 96-core worker | 2,545.17–2,751.96 ms | 27.075–32.31%; every request was eventually accepted while the queue grew | 33.74–33.88 ms |
With v1.1.0, worker CPU use was similar in all six runs, between 55.94 and 57.08 core equivalents, while the latency differed by an order of magnitude. With v1.2.0 every request in all six runs was accepted within one second, and both policies held the same tail. The comparison covers each policy as a whole, including its settings, and does not isolate the effect of topology.
Network and connections#
Every reply carries one complete encoded proof, 176,948 to 186,992 bytes at depth 24. On one 192-core VM the rate with every request within one second stopped at 3,300 requests/s over one connection, where the reply traffic levelled at about 4.96 Gbit/s while server CPU stayed at or below 50% in every run up to 3,400 requests/s. In 15-second screens, two connections to the same server carried 5,000 requests/s within one second at 7.30 Gbit/s. On 96 cores the limit had the same shape: the return budget was full and the replies left at 4.95 Gbit/s on one connection while server CPU stood at 83%.
How to choose#
- Compare candidate deployments at equal total resources and under the same offered load.
- Plan the reply traffic per connection. Multiply the reply rate by the proof size; when one connection would carry more than about 5 Gbit/s in your network, open more connections or spread clients across servers.
- Expect similar CPU use to coexist with very different latency when batching and the serial part of a serving loop differ.
- Confirm the shape you choose over a longer window before you rely on it.
Confirm a setting before relying on it#
The evaluation followed these steps, and they apply to your own service as well:
- Offer requests at a fixed rate on a schedule that does not wait for replies, and measure each latency from the request's scheduled time. A slow service then cannot reduce the load it receives by answering slowly.
- Count every offered request, and keep accepted, late, refused, unsent and unanswered requests apart.
- Screen settings with short runs, then confirm the best one with a longer run. With v1.1.0 on the 192-core VM at 1,150 requests/s, three 15-second screens met one second for every request, and the 60-second confirmation met it for 70.37% of requests.
- Watch the queue length over time. A queue that keeps growing at a constant offered rate means the setting does not sustain that rate, whatever its average throughput. The v1.2.0 confirmation at 3,300 requests/s ran for 30 minutes with a flat queue.
- Report throughput over the completion window including the drain, together with the length of the window. Production integration lists what else to record.
Checklist#
- The depth covers the key space with room to grow, and depth and leaf bound stay fixed for each tree.
- The prover is built for the CPU that runs it, not with the default build.
- Memory is budgeted per job in flight, finished replies are bounded by the return budget, and whole-process memory is measured under the deployed limit.
- The serving mode fits the client's reply order;
continuouswhere replies are matched by identifier. - Workers start at one per core, with the default number of jobs in flight or a batch cap equal to the worker count.
- Reply traffic per connection stays below what one connection carries in your network.
- Candidate deployments are compared at equal total resources.
- The final setting is confirmed with a long run on your own operation mix, with every offered request counted.
Next steps#
- Serving components: the reference server, its modes and settings.
- Serving capacity: what one server sustained on 48, 96 and 192 cores.
- Production integration: what to build around the engine and what to record.
- Benchmark methodology: statistics, timer boundaries and hardware.
- Configuration: every configuration value and its limits.