perf: delegate G2 MSM to generic XYZZ Pippenger#86
Merged
Conversation
Replace the hand-written G2 Pippenger (Jacobian buckets, per-window parallelism) with a thin wrapper that delegates to the generic MSM(F, Fp2).computeWithPool(). This gives G2 the same optimizations as G1: XYZZ bucket coordinates (7M+2S vs 7M+4S per mixed add), batch window normalization via Montgomery's trick, and chunk-based parallelism for better cache locality. G2Point and AffinePoint(Fp2) share identical memory layout, so the bridging is a zero-cost @ptrCast with comptime layout assertions. 339 → 118 lines, public API (msmG2, msmG2Bench) unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The generic MSM's parallel path previously fell back to sequential Pippenger when n < num_threads*256 (chunks too small). This caused a regression for G2 MSM at sizes 256-2048, where the old hand-written code used per-window parallelism. Add pippengerMSMWindowParallel: each thread processes a subset of windows over all points, using XYZZ buckets + batch normalization. Used when n < num_threads*256; chunk-based parallelism still used for larger inputs where cache locality matters more. Benefits both G1 and G2. G2 parallel MSM at N=1024: 6.9ms → 4.4ms. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
MSM(F, Fp2).computeWithPool()(~80 lines of new code)@ptrCastwith comptime layout assertions —G2PointandAffinePoint(Fp2)have identical memory layoutmsmG2,msmG2Bench) unchanged — no caller modifications neededTest plan
zig build test— all unit tests pass, including the arkworks-validated G2 MSM fixture vectorscargo run --release -p zolt -- prove examples/sha256_2048.elftiming comparison🤖 Generated with Claude Code