Skip to content

feat(new-execution): metered execution #1652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
May 20, 2025

Conversation

shuklaayush
Copy link
Contributor

@shuklaayush shuklaayush commented May 15, 2025

  • Added a execute_metered function that keeps a track of trace_heights during execution and suspends execution if the trace height, number of cells or number of interactions goes above a fixed threshold

Resolves INT-3752

Copy link

codspeed-hq bot commented May 15, 2025

CodSpeed Walltime Performance Report

Merging #1652 will improve performances by 14.21%

Comparing feat/new-exec-e2 (2ac2e3f) with feat/new-execution (5da1c54)

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

⚡ 2 improvements
✅ 2 untouched benchmarks
🆕 2 new benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
benchmark_execute[bubblesort] 505.5 ms 451 ms +12.09%
🆕 benchmark_execute[factorial_iterative_u256] N/A 554 ms N/A
benchmark_execute[fibonacci_iterative] 514.5 ms 450.5 ms +14.21%
🆕 benchmark_execute[revm_snailtracer] N/A 618.5 ms N/A

Copy link

codspeed-hq bot commented May 15, 2025

CodSpeed Instrumentation Performance Report

Merging #1652 will improve performances by 15.35%

Comparing feat/new-exec-e2 (2ac2e3f) with feat/new-execution (5da1c54)

Summary

⚡ 1 improvements
✅ 3 untouched benchmarks
🆕 2 new benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
🆕 benchmark_execute[factorial_iterative_u256] N/A 2.1 s N/A
benchmark_execute[fibonacci_iterative] 2 s 1.7 s +15.35%
🆕 benchmark_execute[revm_snailtracer] N/A 1.7 s N/A


self.executors.get_mut(id).map(|executor| {
let insertion_id = self
.insertion_order
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't this O(num_chips)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, but i'm not sure how to avoid it atm. ideally this should be a constant vector and O(1). i added a todo and i'll fix this in a follow up

@shuklaayush shuklaayush marked this pull request as ready for review May 19, 2025 13:51
@shuklaayush shuklaayush requested a review from jonathanpwang May 19, 2025 14:06
@shuklaayush shuklaayush changed the title feat: metered execution feat(new-execution): metered execution May 19, 2025
@@ -7,8 +7,8 @@ use std::{
use itertools::izip;
use openvm_circuit::{
arch::{
AdapterAirContext, AdapterExecutorE1, AdapterTraceStep, ExecutionBridge, ExecutionState,
VecHeapTwoReadsAdapterInterface, VmAdapterAir,
execution_mode::E1E2ExecutionCtx, AdapterAirContext, AdapterExecutorE1, AdapterTraceStep,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm also kinda unsure if we use this folder and wha its relation to rv32im/circuit/src/adapters is...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i just put all the e1/e2 stuff in a new execution_mode folder and it contains this E1E2ExeuctionCtx trait. the trait contains the on_memory_operation callback. this is to make e1 and e2 use the same execute function

.memory_dimensions
.label_to_index((address_space, block_id));

if let Err(insert_idx) = self.leaf_indices.binary_search(&leaf_id) {
Copy link
Contributor

Choose a reason for hiding this comment

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

ok I didn't read this, but it seems too complicated for something that must be done during execution

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can change it to add the height of the Merkle tree every time but that might be a huge overestimate
I think the better way is to not maintain a set here and make GuestMemory return a Boolean indicating a page fault. We can then add a fixed height on every page fault
Fixed height would be height of the merkle tree up to page size + size of the full page subtree

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought for myself that it'll do for now, because if it's too slow, we'll surely notice

Copy link
Contributor

@jonathanpwang jonathanpwang left a comment

Choose a reason for hiding this comment

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

Took a brief look, deferring to @Golovanov399 's review

I think we all have the sense that the structure / traits should be revisited, but I don't think we should block merge.

@Golovanov399
Copy link
Contributor

Yeah I'm all for merging

@jonathanpwang jonathanpwang merged commit 950320b into feat/new-execution May 20, 2025
9 of 28 checks passed
@jonathanpwang jonathanpwang deleted the feat/new-exec-e2 branch May 20, 2025 14:56
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.

3 participants