Repository navigation
perf(precompile): reduce bounds checks in precompile parsing - #3784
Conversation
cargo-asm before/afterMeasured locally with Update after review: the earlier BLS G2 padding read rewrite was dropped, so these numbers reflect the remaining four commits only. Commands used:
Instruction counts below are the bracketed counts reported by cargo-show-asm's symbol selection output.
Bounds/panic-path scan for touched areas:
The BLS MSM individual symbol counts are mixed, but the exact chunk iteration removes the four emitted MSM map-closure The |
33051e1 to
6b4701f
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
|
@0xalpharush this all looks good, should I merge? |
| let x_0 = remove_fp_padding(&input[..PADDED_FP_LENGTH])?; | ||
| let x_1 = remove_fp_padding(&input[PADDED_FP_LENGTH..2 * PADDED_FP_LENGTH])?; | ||
| let y_0 = remove_fp_padding(&input[2 * PADDED_FP_LENGTH..3 * PADDED_FP_LENGTH])?; | ||
| let y_1 = remove_fp_padding(&input[3 * PADDED_FP_LENGTH..])?; | ||
| Ok([x_0, x_1, y_0, y_1]) |
There was a problem hiding this comment.
Previous is probably better as the loop would unwind.
There was a problem hiding this comment.
Removed this change by dropping the perf(precompile): simplify BLS G2 padding reads commit. remove_g2_padding now keeps the previous loop implementation, and the PR description/cargo-asm note have been refreshed for the remaining four commits.
6b4701f to
e22e550
Compare
…luealloy#3784 bluealloy#3823 bluealloy#3840 (#57) Co-authored-by: Saylor Mike <[email protected]> Co-authored-by: Matthias Seitz <[email protected]> Co-authored-by: alpharush <[email protected]> Co-authored-by: a <[email protected]> Co-authored-by: rakita <[email protected]>
Summary
This PR applies a small set of assembly-checked precompile parsing optimizations. The current stack is limited to exact chunk/split handling for BLS/BN254 pair-like inputs and fixed-size byte readers in the BN254 arkworks backend.
The earlier BLS G2 padding read rewrite was removed after review;
remove_g2_paddingnow keeps the previous loop implementation.Commits
perf(precompile): chunk BLS pairing inputsi * PAIRING_INPUT_LENGTHrange construction withchunks_exact(PAIRING_INPUT_LENGTH)plussplit_at.perf(precompile): chunk BLS MSM inputsperf(precompile): chunk BN254 pair inputschunks_exact(PAIR_ELEMENT_LEN)andsplit_at(G1_LEN).perf(precompile): type BN254 reader slicesPrecompileHalt.expectfor documented precondition panics so the panic reason mirrors the function contracts.Validation
cargo fmt --all --checkgit diff --checkcargo test -p revm-precompile --libcargo clippy -p revm-precompile --all-targets --all-featurestypos crates/precompile/src