Skip to content

perf: only do exit check for instructions that can exit#2126

Merged
shuklaayush merged 10 commits into
mainfrom
perf/execute-fewer-exit-checks
Sep 11, 2025
Merged

perf: only do exit check for instructions that can exit#2126
shuklaayush merged 10 commits into
mainfrom
perf/execute-fewer-exit-checks

Conversation

@shuklaayush

@shuklaayush shuklaayush commented Sep 6, 2025

Copy link
Copy Markdown
Collaborator
  • update create_tco_handler macro to create_handler which now automatically sets exit_code based on whether the execute impl returns Result::Err. it acts as a simple wrapper for execute impls that don't return a Result
  • only do exit checks for executors that can exit in tco mode i.e. for execute impls that return Result
  • feature gate all non-tco functions with #[cfg(not(feature = "tco"))]

benchmark comparison

Towards INT-4921

@shuklaayush shuklaayush force-pushed the perf/execute-fewer-exit-checks branch from da7f60f to b372e35 Compare September 6, 2025 00:13
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@shuklaayush shuklaayush force-pushed the perf/execute-fewer-exit-checks branch from 0766db0 to f7526d7 Compare September 6, 2025 07:32
@github-actions

This comment has been minimized.

@shuklaayush shuklaayush force-pushed the feat/execute-pass-state-in-args branch from 75148ad to 4124219 Compare September 6, 2025 09:30
@shuklaayush shuklaayush force-pushed the perf/execute-fewer-exit-checks branch from f7526d7 to 71de2f3 Compare September 6, 2025 09:37
@github-actions

This comment has been minimized.

@shuklaayush shuklaayush force-pushed the perf/execute-fewer-exit-checks branch from 71de2f3 to 8b49167 Compare September 6, 2025 10:11
@github-actions

This comment has been minimized.

Base automatically changed from feat/execute-pass-state-in-args to main September 7, 2025 00:03
@shuklaayush shuklaayush force-pushed the perf/execute-fewer-exit-checks branch from 8b49167 to b775cb8 Compare September 7, 2025 05:14
@github-actions

This comment has been minimized.

Comment thread crates/vm/derive/src/lib.rs Outdated
Comment thread crates/vm/derive/src/lib.rs Outdated

@jonathanpwang jonathanpwang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The macro change LGTM.
But how can we statically / non-manually ensure that the e1/2_impl never creates an error? The current way where I assume you manually checked each function for whether it can error or not doesn't seem very good/maintanable. I think I'd prefer if we actually had a different function signature for those functions and the derive macro used the function signature accordingly.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

macros for everyone!

Comment thread crates/vm/derive/src/tco.rs Outdated

@jonathanpwang jonathanpwang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM except #exit_check seems unused/empty?

I confirmed that the exit code is never set directly in an *_impl and now always returned in the Result.

@github-actions

Copy link
Copy Markdown
group app.proof_time_ms app.cycles app.cells_used leaf.proof_time_ms leaf.cycles leaf.cells_used
verify_fibair (+2 [+0.7%]) 275 322,610 2,058,654 - - -
fibonacci (+12 [+1.2%]) 1,026 1,500,210 1,060,232 - - -
regex (-10 [-0.3%]) 2,950 4,108,483 13,403,604 - - -
ecrecover (-34 [-3.5%]) 937 140,497 2,274,628 - - -
pairing (-12 [-0.8%]) 1,546 1,882,939 23,722,622 - - -

Commit: 0e94729

Benchmark Workflow

@shuklaayush shuklaayush merged commit abba399 into main Sep 11, 2025
43 checks passed
@shuklaayush shuklaayush deleted the perf/execute-fewer-exit-checks branch September 11, 2025 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants