perf(profile): optimize the math cores so cargo test --workspace is runnable - #71
perf(profile): optimize the math cores so cargo test --workspace is runnable#71Nexlab-One wants to merge 1 commit into
cargo test --workspace is runnable#71Conversation
… runnable
At dev/test opt-level 0 the crypto math is 1-2 orders of magnitude slow and
the local workspace test gate does not terminate in practical time. Measured
on a warm cache (test binaries run directly, so no compile time in the
numbers): 8 binaries exceeded a 90s cap, the `lib-q` umbrella unit binary
exceeded 420s, and a dozen more ran 25-70s each. CI already knew this
per-crate via its skip lists; the local gate had no answer.
Two layers, extending the existing fn-dsa precedent in this file:
* `[profile.dev.package."*"]` at opt-level 2 for all external deps. The
"*" spec never matches workspace members, so members keep dev settings
unless named below.
* Named entries at opt-level 2 for 49 crates carrying heavy in-crate math:
the hash stack (Keccak/SHA3/K12/Poseidon - the shared substrate under
SLH-DSA, SHAKE, the RNGs and HQC), the algorithm cores, the
lattice/threshold/proof crates, and the STARK+plonky proving stacks.
Measured before -> after, same binaries, same machine:
lib-q-slh-dsa >90s -> 11.3s
lib-q-lattice-zkp >90s -> 11.2s
lib-q-zkp >90s -> 20.7s
lib-q-hqc simd_correctness >90s -> 8.4s
lib-q-zk-encryption-proof >90s -> 111.7s (completes)
lib-q-blind-token >90s -> 219.8s (completes)
lib-q-sig slh_dsa_context 68.7s -> 3.5s
lib-q-sig no_std 65.6s -> 3.1s
lib-q-mve 59.1s -> 2.4s
lib-q-sca-test 31.6s -> 1.6s
lib-q-ring-sig interop 28.0s -> 2.0s
lib-q-dkg wire_roundtrip 27.8s -> 2.1s
controls (types/utils/keccak) unchanged
NO SAFETY CHECK IS WEAKENED. Only `opt-level` is overridden; `debug-assertions`
and `overflow-checks` inherit from dev/test and stay ON - verified per unit via
`cargo --unit-graph`, including the `#[cfg(debug_assertions)]` constraint
checkers inside the STARK/plonky provers. Zero tests were ignored, gated, or
removed.
All 11 timing-sensitive suites still pass (k12/sha3 constant_time and
performance, every hardened_dudect_smoke, threshold-kem-lattice perf_probe).
Their codegen conditions do change - closer to what ships than unoptimized
debug, but a different regime - so a CAUTION comment names them in this file.
Also corrects a comment that claimed a `[profile.dev.package]` override cannot
reach the root crate being tested. On nightly-2026-07-24 it does (the test
profile inherits dev's package overrides), verified via `--unit-graph`; one
mechanism therefore covers both dependency and root positions.
Thin API/type/util crates (lib-q, core, sig, random, types, utils, transcript,
the AEADs) deliberately stay at opt-level 0 for debuggability - measurement
confirmed they are fast once the math they call is optimized. Compile cost is
7m23s one-time on a warm cache; dev and test artifact universes stay unified,
so there is no double build, and incremental check/build on unlisted crates is
unchanged.
Three binaries remain capped after this change - lib-q-fn-dsa unit,
lib-q-sig/crypto_operations_tests, and the lib-q umbrella. That is NOT
slowness and this commit does not address it: they livelock, and only under
`--all-features`, because the `no_avx2` feature selects a portable FN-DSA
keygen path that appears not to terminate. Tracked separately.
Complements origin/ci/trim-full-workspace-test-matrix rather than duplicating
it: that branch is CI-row-scoped, this is the workspace-profile layer beneath
it. No CI files touched here.
|
Refinement on the out-of-scope note, now that I've bisected it — the characterisation in the PR description is incomplete. I wrote that the Bisected by restricting the test loop to one
A keygen on 8 coefficients running over a minute is a livelock, not slowness. The dispatcher compiles its AVX2 branch only for Tracked on the board as None of this affects the diff in this PR, which is manifest-only. |
🔒 Security Validation ReportGenerated: Wed Jul 29 00:23:25 UTC 2026 📊 Summary
✅ Overall Security Status: PASSEDAll critical security validations passed successfully. 🔍 DetailsThis report covers:
📋 Next Steps✅ Security validation passed. Code is ready for deployment. ✅ Security validation passed! This code meets all security requirements. |
🔍 Pull Request SummaryGenerated: Wed Jul 29 00:26:27 UTC 2026 📋 Validation Results
✅ Overall Status: PASSED🔒 Security Checklist
📝 Review NotesPlease review the security implications of this change carefully. ✅ Automated validation passed! This PR is ready for review. |
Problem
At dev/test
opt-level = 0the crypto math is 1-2 orders of magnitude slow and the local workspace test gate does not terminate in practical time. Measured on a warm cache, running test binaries directly so no compile time is in the numbers: 8 binaries exceeded a 90s cap, thelib-qumbrella unit binary exceeded 420s, and a dozen more ran 25-70s each. CI already knew this per-crate via its skip lists; the local gate had no answer.Change
Two layers, extending the existing fn-dsa precedent already in this file:
[profile.dev.package."*"]at opt-level 2 for all external deps. The"*"spec never matches workspace members, so members keep dev settings unless named.Measured before → after
lib-q-slh-dsalib-q-lattice-zkplib-q-zkplib-q-hqc simd_correctnesslib-q-zk-encryption-prooflib-q-blind-tokenlib-q-sig slh_dsa_contextlib-q-sig no_stdlib-q-mvelib-q-sca-testlib-q-ring-sig interoplib-q-dkg wire_roundtripNo safety check is weakened
Only
opt-levelis overridden.debug-assertionsandoverflow-checksinherit from dev/test and stay ON — verified per unit viacargo --unit-graph, including the#[cfg(debug_assertions)]constraint checkers inside the STARK/plonky provers. Zero tests ignored, gated, or removed.All 11 timing-sensitive suites still pass (k12/sha3
constant_timeandperformance, everyhardened_dudect_smoke,threshold-kem-lattice perf_probe). Their codegen conditions do change — closer to what ships than unoptimized debug, but a different regime — so a CAUTION comment in the file names them.This also corrects a comment that claimed a
[profile.dev.package]override cannot reach the root crate being tested. Onnightly-2026-07-24it does; one mechanism covers both dependency and root positions.Compile cost is 7m23s one-time on a warm cache. Dev and test artifact universes stay unified, so no double build, and incremental check/build on unlisted crates is unchanged.
Out of scope
Three binaries remain capped after this change —
lib-q-fn-dsaunit,lib-q-sig/crypto_operations_tests, and thelib-qumbrella. That is not slowness and this PR does not fix it: they livelock, only under--all-features, because theno_avx2feature selects a portable FN-DSA keygen path that appears not to terminate. Filed separately — it has a potential non-x86 correctness implication.Complements
origin/ci/trim-full-workspace-test-matrixrather than duplicating it: that branch is CI-row-scoped, this is the workspace-profile layer beneath it. No CI files touched.