Skip to content

Optimize EIP-196 AltBn128 EcAdd and EcMul#9570

Merged
siladu merged 4 commits intobesu-eth:mainfrom
siladu:improve-ecadd-perf
Dec 17, 2025
Merged

Optimize EIP-196 AltBn128 EcAdd and EcMul#9570
siladu merged 4 commits intobesu-eth:mainfrom
siladu:improve-ecadd-perf

Conversation

@siladu
Copy link
Copy Markdown
Contributor

@siladu siladu commented Dec 15, 2025

PR description

Pull in changes from besu-eth/besu-native#301

Key Improvements:

  • 🚀 EcAdd (average cases): Up to 2.56x faster (149% throughput increase)
  • 🚀 EcAdd (worst cases): 1.3-1.4x faster (32-36% throughput increase)
  • ✅ EcMul (scalar multiplication average cases) : ~8-9% faster (thanks to gnark-crypto v0.19.2)
  • ✅ Pairings: Slightly improved (~0.6%)
  | Operation    | Before (ns) | After (ns) | Speedup  | Throughput Gain |
  |--------------|-------------|------------|----------|-----------------|
  | EcAdd        | 1,618.3     | 649.8      | 2.49x 🚀 | +138%           |
  | EcAddMarius  | 4,173.7     | 3,133.5    | 1.33x    | +33%            |
  | EcAddAmez1   | 4,019.2     | 3,053.7    | 1.32x    | +32%            |
  | EcAddAmez2   | 4,055.4     | 3,046.6    | 1.33x    | +33%            |
  | EcAddAmez3   | 4,074.4     | 3,081.2    | 1.32x    | +31%            |
  | EcAddCase0   | 4,185.6     | 3,024.6    | 1.38x    | +34%            |
  | EcAddCase1   | 4,040.7     | 2,942.1    | 1.37x    | +36%            |
  | EcAddCase100 | 1,584.8     | 618.4      | 2.56x 🚀 | +148%           |
  | EcAddCase106 | 1,412.5     | 561.4      | 2.52x 🚀 | +149%           |
  | mul1         | 51,909.7    | 48,001.8   | 1.08x    | +8%             |
  | mul2         | 51,479.8    | 47,235.8   | 1.09x    | +9%             |
  | 2 pairings   | 442,882.6   | 440,668.6  | 1.01x    | +0.6%           |
  | 4 pairings   | 628,526.7   | 624,919.0  | 1.01x    | +0.6%           |
  | 6 pairings   | 814,240.0   | 809,483.1  | 1.01x    | +0.6%           |

benchmark executed on m6a.2xlarge - 4c/8t 32 GB

More detailed results: besu-eth/besu-native#301

Testing

Profiling

Before PR on the left, this PR on the right - shows main improvement is removal of IntByReference for tracking output size and parsing error strings which were only logged at TRACE level. In this PR, we log an error code at DEBUG level, which can be looked up if necessary. Avoiding passing Strings across the native boundary is also an improvement.

Screenshot 2025-12-15 at 5 12 38 pm

Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
Copilot AI review requested due to automatic review settings December 15, 2025 07:26
Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Contributor

@ahamlat ahamlat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@siladu siladu enabled auto-merge (squash) December 17, 2025 11:38
@siladu siladu merged commit d1c964c into besu-eth:main Dec 17, 2025
46 checks passed
@siladu siladu deleted the improve-ecadd-perf branch December 17, 2025 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants