Skip to content

Conversation

@JereSalo
Copy link
Contributor

@JereSalo JereSalo commented Nov 28, 2025

Motivation

  • Improve perf with SP1

Description

Based on SP1 Docs we should compile with lto thin, true or fat and codegen-units 1.

Ethrex Replay Build Command: cargo build --release --profile sp1,profiling

Branch Empty 1 Transfer 100 Transfers 23897700 (30M) 23897687 (33M) 23897646 (55M) 23897709 (60M)
main (Gas) 6,395,981 7,562,712 45,607,202 992,588,338 1,636,706,753 2,403,112,555 1,592,397,865
this branch (Gas) 5,780,387 7,342,824 43,493,602 967,103,357 1,605,060,723 2,355,045,830 1,548,978,533
% improvement 9.62% 2.91% 4.63% 2.57% 1.93% 2.00% 2.73%
main (Cycles) 1,117,654 1,402,868 20,150,510 723,222,391 1,325,458,588 1,852,238,963 1,209,370,294
this branch (Cycles) 1,019,876 1,296,104 17,718,398 692,676,359 1,289,227,624 1,796,213,076 1,158,792,828
% improvement (Cycles) 8.75% 7.61% 12.07% 4.22% 2.73% 3.02% 4.18%

@github-actions github-actions bot added L2 Rollup client performance Block execution throughput and performance in general labels Nov 28, 2025
@github-actions
Copy link

Lines of code report

Total lines added: 10
Total lines removed: 0
Total lines changed: 10

Detailed view
+----------------------------------------------------+-------+------+
| File                                               | Lines | Diff |
+----------------------------------------------------+-------+------+
| ethrex/crates/l2/prover/src/guest_program/build.rs | 203   | +10  |
+----------------------------------------------------+-------+------+

@JereSalo JereSalo changed the title perf(l2): build sp1 with recommended settings perf(l2): build zkVMs with recommended settings Nov 29, 2025
@JereSalo JereSalo marked this pull request as ready for review November 29, 2025 00:02
Copilot AI review requested due to automatic review settings November 29, 2025 00:03
Copilot finished reviewing on behalf of JereSalo November 29, 2025 00:04
Copy link
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.

Pull request overview

This PR introduces performance optimizations for zkVM builds by configuring the Cargo release profile with recommended compiler settings from the SP1 documentation. The changes set lto = "thin" and codegen-units = 1 to improve execution performance, resulting in 2-10% gas and cycle improvements across various test scenarios.

  • Added a helper function to configure Cargo profile environment variables for LTO and codegen optimization
  • Applied these settings consistently across all four zkVM backends (RISC0, SP1, Zisk, and OpenVM)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

}

/// Force the nested guest builds to match the workspace release profile.
pub fn set_guest_release_profile_env() {
Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

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

The pub visibility modifier is unnecessary for this function in a build script. Build scripts don't export their functions to other modules. Consider making this function private by removing pub.

Suggested change
pub fn set_guest_release_profile_env() {
fn set_guest_release_profile_env() {

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, I did this in order not to get the dead code clippy lint. I will change it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L2 Rollup client performance Block execution throughput and performance in general

Projects

Status: No status
Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants