precompiles: Precompute Miller loop lines for KZG trusted setup point#1537
Draft
chfast wants to merge 1 commit into
Draft
precompiles: Precompute Miller loop lines for KZG trusted setup point#1537chfast wants to merge 1 commit into
chfast wants to merge 1 commit into
Conversation
Each kzg_verify_proof call recomputed the Miller loop lines for the fixed trusted setup point [s]₂ on every invocation. blst exposes blst_precompute_lines() / blst_miller_loop_lines() to split the per- G2-point line tables from the per-G1-point loop. Compute the 68-entry (~19 KB) line table for KZG_SETUP_G2_1 once on first call (function-local static, C++11 thread-safe) and pass it to every subsequent Miller loop. The b2 parameter (always KZG_SETUP_G2_1) is dropped from pairings_verify since the table replaces it. Bench (Release on chfast's 32-thread box, median of 15 reps, 3 s each; freshly built on the same machine state, alternated runs): before: 1598 ns/op, 31.30 Mgas/s after: 1504 ns/op, 33.31 Mgas/s (-5.9% time, +6.4% mgas/s)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1537 +/- ##
=======================================
Coverage 96.97% 96.97%
=======================================
Files 162 162
Lines 14447 14452 +5
Branches 3383 3383
=======================================
+ Hits 14010 14015 +5
Misses 307 307
Partials 130 130
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Each kzg_verify_proof call recomputed the Miller loop lines for the fixed trusted setup point [s]₂ on every invocation. blst exposes blst_precompute_lines() / blst_miller_loop_lines() to split the per- G2-point line tables from the per-G1-point loop.
Compute the 68-entry (~19 KB) line table for KZG_SETUP_G2_1 once on first call (function-local static, C++11 thread-safe) and pass it to every subsequent Miller loop. The b2 parameter (always KZG_SETUP_G2_1) is dropped from pairings_verify since the table replaces it.
Bench (Release on chfast's 32-thread box, median of 15 reps, 3 s each; freshly built on the same machine state, alternated runs):
before: 1598 ns/op, 31.30 Mgas/s
after: 1504 ns/op, 33.31 Mgas/s (-5.9% time, +6.4% mgas/s)