Add SDIV, MOD, SMOD, ADDMOD, EXP and SIGNEXTEND operations for EVM v2#10186
Closed
parthdagia05 wants to merge 1 commit intobesu-eth:mainfrom
Closed
Add SDIV, MOD, SMOD, ADDMOD, EXP and SIGNEXTEND operations for EVM v2#10186parthdagia05 wants to merge 1 commit intobesu-eth:mainfrom
parthdagia05 wants to merge 1 commit intobesu-eth:mainfrom
Conversation
… with JMH benchmarks Implements the remaining arithmetic opcodes for the EVM v2 long[]-based stack, with zero heap allocation on the hot path. Includes JMH benchmarks showing 1.2x-2.9x performance improvement over v1 implementations. Signed-off-by: Parth Dagia <parth.24bcs10414@sst.scaler.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.
PR description
Continues the EVM v2 implementation started in #10105 and follows the pattern established in #10154 and #10171.
This PR adds the remaining arithmetic opcodes to the EVM v2
long[]-based stack:SDIV(0x05),MOD(0x06),SMOD(0x07),ADDMOD(0x08),EXP(0x0a), andSIGNEXTEND(0x0b).Changes
SDIV(0x05),MOD(0x06),SMOD(0x07),ADDMOD(0x08),EXP(0x0a), andSIGNEXTEND(0x0b) opcodes for the EVM v2long[]-based stack, with zero heap allocation on the hot pathSDivOperationV2,ModOperationV2,SModOperationV2,AddModOperationV2,ExpOperationV2, andSignExtendOperationV2operation classes utilizingUInt256for 256-bit arithmetic directly on the flatlong[]operand stackTernaryOperationBenchmarkV2base class for benchmarking ternary operations (3 inputs → 1 output)Benchmarks
Baseline (v1 on main)
Benchmark (caseName) Mode Cnt Score Error Units
SDivOperationBenchmark.executeOperation SDIV_FULL_RANDOM avgt 15 114.672 ± 2.897 ns/op
ModOperationBenchmark.executeOperation FULL_RANDOM avgt 15 107.074 ± 6.765 ns/op
SModOperationBenchmark.executeOperation FULL_RANDOM avgt 15 127.728 ± 12.489 ns/op
AddModOperationBenchmark.executeOperation FULL_RANDOM avgt 15 156.767 ± 16.190 ns/op
ExpOperationBenchmark.executeOperation N/A avgt 15 10313.733 ± 1294.918 ns/op
SignExtendOperationBenchmark.executeOperation N/A avgt 15 70.865 ± 6.442 ns/op
With this PR (v2)
Benchmark Mode Cnt Score Error Units
SDivOperationBenchmarkV2.executeOperation avgt 15 64.162 ± 4.224 ns/op
ModOperationBenchmarkV2.executeOperation avgt 15 64.207 ± 8.703 ns/op
SModOperationBenchmarkV2.executeOperation avgt 15 68.933 ± 3.234 ns/op
AddModOperationBenchmarkV2.executeOperation avgt 15 116.354 ± 32.339 ns/op
ExpOperationBenchmarkV2.executeOperation avgt 15 8557.310 ± 768.777 ns/op
SignExtendOperationBenchmarkV2.executeOperation avgt 15 24.186 ± 2.781 ns/op
Summary
Fixed Issue(s)
fixes #10131
Thanks for sending a pull request! Have you done the following?
doc-change-requiredlabel to this PR if updates are required.Locally, you can run these tests to catch failures early:
./gradlew spotlessApply./gradlew build./gradlew acceptanceTest./gradlew integrationTest./gradlew ethereum:referenceTests:referenceTests