Skip to content

perf: pass state variables by value in tco exec handlers#2121

Merged
jonathanpwang merged 12 commits into
mainfrom
feat/execute-pass-state-in-args
Sep 7, 2025
Merged

perf: pass state variables by value in tco exec handlers#2121
jonathanpwang merged 12 commits into
mainfrom
feat/execute-pass-state-in-args

Conversation

@shuklaayush

@shuklaayush shuklaayush commented Sep 3, 2025

Copy link
Copy Markdown
Collaborator
  • pass pc, instret and instret_end/max_execution_cost/segment_check_insns by value in execution handlers to get them to be passed in registers
  • add likely, unlikely hints for suspension/termination in tco

benchmark comparison

Towards INT-4921

@shuklaayush shuklaayush changed the title feat: update execute handlers to take ownership of VmExecState feat: pass VmExecState by value in exec handlers Sep 3, 2025
@shuklaayush shuklaayush force-pushed the feat/execute-pass-state-in-args branch from 8b6e584 to e65a3d2 Compare September 3, 2025 20:12
@github-actions

This comment has been minimized.

@shuklaayush shuklaayush changed the title feat: pass VmExecState by value in exec handlers feat: pass pc, 'instret by value in tco` exec handlers Sep 4, 2025
@shuklaayush shuklaayush changed the title feat: pass pc, 'instret by value in tco` exec handlers feat: pass pc, instret by value in tco exec handlers Sep 4, 2025
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@shuklaayush shuklaayush force-pushed the feat/execute-pass-state-in-args branch from 381715d to c521941 Compare September 4, 2025 22:20
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@shuklaayush shuklaayush force-pushed the feat/execute-pass-state-in-args branch from 642a8c4 to 9624590 Compare September 5, 2025 19:05
@github-actions

This comment has been minimized.

@shuklaayush shuklaayush marked this pull request as ready for review September 5, 2025 20:19
@shuklaayush shuklaayush changed the title feat: pass pc, instret by value in tco exec handlers feat: pass pc, instret, instret_end by value in tco exec handlers Sep 5, 2025
@shuklaayush shuklaayush changed the title feat: pass pc, instret, instret_end by value in tco exec handlers feat: pass state variables by value in tco exec handlers Sep 5, 2025
@github-actions

This comment has been minimized.

@shuklaayush shuklaayush force-pushed the feat/execute-pass-state-in-args branch from cd4c360 to 1075439 Compare September 5, 2025 20:41
@github-actions

This comment has been minimized.

@shuklaayush shuklaayush changed the title feat: pass state variables by value in tco exec handlers perf: pass state variables by value in tco exec handlers Sep 5, 2025
Comment thread crates/vm/derive/src/tco.rs Outdated
Comment thread crates/vm/src/arch/interpreter.rs Outdated
Comment thread crates/vm/src/system/public_values/execution.rs Outdated
Comment thread crates/vm/derive/src/tco.rs Outdated

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.

nit: perhaps it'd be nice to have an inst_inc! or inst_advance!` macro to make these changes more uniform for later

@shuklaayush shuklaayush Sep 6, 2025

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

i'll keep this for later when i try to get rid of pc

@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.

Overall it was not as bad as I thought. I do wonder if we could use some more macros to clean up all the places you had to change, but that's another story.

LGTM except the pc, instret fields in VmState should now be private and you should only be allowed to mutate them via some conscious decision via a function.

@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.

@shuklaayush shuklaayush force-pushed the feat/execute-pass-state-in-args branch from 75148ad to 4124219 Compare September 6, 2025 09:30
@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Sep 6, 2025

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 (-5 [-1.8%]) 268 322,610 2,058,654 - - -
fibonacci (-3 [-0.3%]) 1,017 1,500,210 1,060,232 - - -
regex (+9 [+0.3%]) 2,976 4,108,483 13,403,604 - - -
ecrecover (+7 [+0.7%]) 969 140,497 2,275,066 - - -
pairing 1,542 1,882,939 23,722,622 - - -

Commit: 9242af6

Benchmark Workflow

@jonathanpwang jonathanpwang merged commit 9b3386b into main Sep 7, 2025
44 checks passed
@jonathanpwang jonathanpwang deleted the feat/execute-pass-state-in-args branch September 7, 2025 00:03
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