Skip to content

bench: give DSA parameter generation a median tape at each size - #4301

Merged
reaperhulk merged 1 commit into
mainfrom
claude/dsa-parameters-bench-median
Nov 6, 2026
Merged

reaperhulk merged 1 commit into
mainfrom
claude/dsa-parameters-bench-median

Conversation

@alex

@alex alex commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

dsa_generate_parameters timed verified-garbage on a single fixed tape per size, fixed_tape(bits). How long a parameter search takes depends on how many seeds and candidates its tape rejects, so that number was one draw from a wide distribution, compared against OpenSSL's average over fresh draws. The 1024-bit tape was the slowest of the nine seeds below: about 4× the median.

This takes each size's tape from the seed whose search is the median of seeds bits to bits + 8: 1027, 2050 and 3075. As before, every iteration searches the same tape. This is the counterpart of RSA keygen's median tape (#4271), but ranked by search time rather than by octets drawn. The refillable-tape search usually reads its whole tape from one fill of 512 · p_len octets, so the octets drawn don't say how long the search was.

How the seeds were ranked

The best of three timings of each seed's search, on x86-64 with VG_CPU_FEATURES=none (the baseline implementations), in a scratch program calling Parameters::generate_with_rng as the benchmark does:

Size Times of seeds bits…bits + 8, sorted (ms) Median seed Old seed (bits)
1024 19, 20, 23, 27, 50, 50, 59, 73, 208 1027 (50 ms) 1024 (208 ms, the slowest)
2048 225, 230, 275, 417, 437, 460, 466, 472, 1115 2050 (437 ms) 2048 (230 ms)
3072 1099, 1199, 2093, 2693, 3036, 3243, 4888, 16183, 18342 3075 (3036 ms) 3072 (2693 ms)

The ranking was done once, on x86-64. Since #4304 every target runs the refillable-tape search, which reads the same seeds, candidates and witnesses from a tape on all of them, and its cost is the Miller–Rabin rounds those candidates take. So the ranking holds on every target. The comment in the benchmark says so.

Benchmark

Benchmarks run 42184897360 (arches: x86_64, modules: dsa, against main at 7f03ff1b). Both sides run this branch's benchmark harness, so both use the new seeds. The library is unchanged, and so are the times:

Benchmark Base Head Change
dsa_generate_parameters/1024 45.73 ms 43.60 ms 4.7% faster
dsa_generate_parameters/2048 279.79 ms 287.22 ms 2.7% slower
dsa_generate_parameters/3072 1883.99 ms 1883.72 ms 0.0% faster

The before/after of the tapes themselves is in the ranking table above. The branch has since been rebased onto main after #4304. That rebase changed only this file's comment: the three-tape path it mentioned is gone.

One file changes, bench/benches/primitives/dsa_parameters.rs. No library code, tests or proofs change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TKUFHGhkN8REQLPW8yxN5A

Each size's fixed tape was one draw of a search whose length varies: the
1024-bit one was the slowest of nine seeds, 4x the median. Take each
size's tape from the seed whose refillable-tape search is the median of
nine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHGhkN8REQLPW8yxN5A
@alex
alex force-pushed the claude/dsa-parameters-bench-median branch from cf0a3ab to ded40c0 Compare November 6, 2026 10:34
@reaperhulk
reaperhulk added this pull request to the merge queue Nov 6, 2026
Merged via the queue into main with commit 5074da6 Nov 6, 2026
15 checks passed
@reaperhulk
reaperhulk deleted the claude/dsa-parameters-bench-median branch November 6, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants