perf(precompile): use malachite for std modexp#3767
Draft
Rjected wants to merge 1 commit into
Draft
Conversation
Merging this PR will improve performance by 62.42%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | modexp[marius-1-even] |
301.8 µs | 353.3 µs | -14.6% |
| ⚡ | Simulation | modexp[mod_1024_exp_2] |
1,883.8 µs | 486.1 µs | ×3.9 |
| ⚡ | Simulation | modexp[mod_odd_256b_exp_1024] |
22 ms | 9.3 ms | ×2.4 |
| ⚡ | Simulation | modexp[mod_even_32b_exp_256] |
161.8 µs | 124.7 µs | +29.77% |
| ⚡ | Simulation | modexp[mod_even_8b_exp_896] |
157 µs | 141.6 µs | +10.83% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing dan/malachite-modexp (b26ead9) with main (84fe60c)
Footnotes
-
1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports. ↩
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.
Switches the default std MODEXP backend from
aurora-engine-modexptomalachite::NaturalwithModPow::mod_pow. Thegmpfeature still takes precedence when explicitly enabled, and no-std builds continue to use the existing Aurora implementation.The Malachite path imports base, exponent, and modulus as big-endian base-256 digits, handles zero modulus the same way as the previous backend, and reduces the base before calling
mod_powbecause Malachite requires the base to already be reduced modulo the modulus. The new dependency is wired only throughrevm-precompile/stdwithdefault-features = falseandnaturals_and_integersenabled.Validated with:
cargo check -p revm-precompilecargo check -p revm-precompile --no-default-featurescargo test -p revm-precompile modexpcargo test -p revm-precompile modexp --no-default-featurescargo check -p revm-precompile --features gmpcargo test -p revm-precompile modexp --features gmpcargo check -p revm-precompile --all-featurescargo bench -p revm-precompile --bench bench modexp --no-runcargo fmt --all --checkgit diff --check