Skip to content

test(precompile): add benchmarkoor bls12-381 benches#3766

Draft
Rjected wants to merge 5 commits into
mainfrom
dan/bls12-381-precompile-benches
Draft

test(precompile): add benchmarkoor bls12-381 benches#3766
Rjected wants to merge 5 commits into
mainfrom
dan/bls12-381-precompile-benches

Conversation

@Rjected

@Rjected Rjected commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Adds benchmarkoor-named Criterion coverage for the EIP-2537 BLS12-381 precompiles using the EF/Jochemnet compute cases from NethermindEth/gas-benchmarks release amsterdam-repricings-v5.2.0.

The BLS bench matrix now covers the cached test_bls12_381[...] cases, fixed MSM sizes k=1,16,64,128, pairing sizes num_pairs=1,3,6,12,24, and uncachable variants for add/MSM/map/pairing-style inputs. The MSM inputs keep the benchmarkoor scalar as Spec.Q; the uncachable MSM variants vary only the point input.

The MSM implementation now reduces scalars modulo the subgroup order before deciding whether to skip a term. This means scalar values equal to r/Spec.Q take the zero-scalar path and return encoded infinity when every term reduces to zero. The blst backend also skips MSM terms whose point is infinity after on-curve validation, avoiding the subgroup/scalar/MSM work for the later iterations of benchmarkoor-style uncachable MSM loops.

@codspeed-hq

codspeed-hq Bot commented Jun 19, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 165 untouched benchmarks
🆕 31 new benchmarks
⏩ 17 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
🆕 Simulation test_bls12_381_uncachable[bls12_fp_to_g1] N/A 244.4 µs N/A
🆕 Simulation test_bls12_381_uncachable[bls12_fp_to_g2] N/A 861.5 µs N/A
🆕 Simulation test_bls12_381_uncachable[bls12_g1add] N/A 28.9 µs N/A
🆕 Simulation test_bls12_381_uncachable[bls12_g1msm] N/A 8.9 µs N/A
🆕 Simulation test_bls12_381_uncachable[bls12_g2add] N/A 43.8 µs N/A
🆕 Simulation test_bls12_381_uncachable[bls12_g2msm] N/A 12.6 µs N/A
🆕 Simulation test_bls12_381[bls12_fp_to_g1] N/A 244.1 µs N/A
🆕 Simulation test_bls12_381[bls12_fp_to_g2] N/A 861.3 µs N/A
🆕 Simulation test_bls12_381[bls12_g1add] N/A 28.7 µs N/A
🆕 Simulation test_bls12_381[bls12_g1msm] N/A 30.1 ms N/A
🆕 Simulation test_bls12_381[bls12_g2add] N/A 43.6 µs N/A
🆕 Simulation test_bls12_381[bls12_g2msm] N/A 19.6 ms N/A
🆕 Simulation test_bls12_381[bls12_pairing_check] N/A 4.4 ms N/A
🆕 Simulation test_bls12_g1_msm[k=1] N/A 245.9 µs N/A
🆕 Simulation test_bls12_g1_msm[k=128] N/A 30.1 ms N/A
🆕 Simulation test_bls12_g1_msm[k=16] N/A 3.8 ms N/A
🆕 Simulation test_bls12_g1_msm[k=64] N/A 15.1 ms N/A
🆕 Simulation test_bls12_g2_msm[k=1] N/A 319.5 µs N/A
🆕 Simulation test_bls12_g2_msm[k=128] N/A 39.2 ms N/A
🆕 Simulation test_bls12_g2_msm[k=16] N/A 4.9 ms N/A
... ... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.


Comparing dan/bls12-381-precompile-benches (bb5a88e) with main (84fe60c)

Open in CodSpeed

Footnotes

  1. 17 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@mark0-cn

Copy link
Copy Markdown
Contributor

I opened #3770 against this branch as a small follow-up.

While going through the MSM changes here I noticed the infinity-point skip (68ade1a) only landed in the blst backend — the arkworks fallback still pushes points at infinity into the MSM (it only picked up the zero-scalar skip). #3770 brings arkworks to parity by mirroring the read_g1_msm / read_g2_msm helpers, and also:

  • fixes the read_scalar doc comment in blst.rs, which now contradicts itself — it reduces modulo the subgroup order r via blst_scalar_from_be_bytes, but the doc still says it doesn't reduce;
  • adds arkworks unit tests plus backend-agnostic integration tests asserting an infinity point paired with a non-zero scalar produces the same result as omitting it.

Output is unchanged in both backends (an infinity point contributes nothing to the MSM); it just avoids feeding infinity into the MSM and the subgroup check. The PR targets this branch, so the diff is only the follow-up — feel free to fold it in or use it as a reference. 🙏

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