Skip to content

feat(presim): constrain number of sim tasks#481

Closed
akundaz wants to merge 2 commits intomainfrom
ash-ursmuxwvvpvt
Closed

feat(presim): constrain number of sim tasks#481
akundaz wants to merge 2 commits intomainfrom
ash-ursmuxwvvpvt

Conversation

@akundaz
Copy link
Copy Markdown
Contributor

@akundaz akundaz commented Apr 27, 2026

1st commit: refactoring pool insertion to happen after sending on a channel. This will make it easier later on to put the presim at the right spot (before bundles get into the reth pool).

2nd commit: Added a flag to constrain the number of simultaneously running presim tasks

@akundaz akundaz self-assigned this Apr 27, 2026
Comment thread crates/op-rbuilder/src/pool.rs Outdated
Comment thread crates/op-rbuilder/src/revert_protection.rs
Comment thread crates/op-rbuilder/src/pool.rs
Comment thread crates/op-rbuilder/src/pool.rs Outdated
Comment thread crates/op-rbuilder/src/pool.rs Outdated
@akundaz akundaz force-pushed the ash-ursmuxwvvpvt branch 2 times, most recently from 9658148 to 3d97dbe Compare April 27, 2026 16:08
Comment thread crates/op-rbuilder/src/pool.rs Outdated
@akundaz akundaz changed the title refactor: insert into pool via channel feat(presim): constrain number of sim tasks Apr 27, 2026
Copy link
Copy Markdown
Member

@julio4 julio4 left a comment

Choose a reason for hiding this comment

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

I have a slight feeling that this whole module adds some unnecessary complexity. In the current form it would be better to keep validation + response at the rpc level and only spawn this "pool presim" worker as a post-hook after pool insertion. If the goal is to have an invariant every bundle need to be simulated before being added to the pool, then it would be better to first implement changes to make that possible.

long = "builder.presim-max-concurrency",
env = "PRESIM_MAX_CONCURRENCY"
)]
pub presim_max_concurrency: Option<usize>,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Need to validate >0 as channel(0) would panic.

};

match &bounded_sender {
Some(sender) => sender.send(fut).await.unwrap(),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When presim queue is full the send(fut).await blocks the single insertion worker so new RPC requests would pile up in the unbounded pool_rx. Consider using try_send and handle the TrySendError::Full with atleast a metric or log.

let bounded_sender = max_concurrency.map(|max| {
let (sender, receiver) = mpsc::channel(max);
runtime.spawn_task(async move {
let _ = ReceiverStream::new(receiver)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe a PresimJob struct would be clearer instead of sending future through the channel, and you create the future here.

@akundaz
Copy link
Copy Markdown
Contributor Author

akundaz commented Apr 30, 2026

Closing this PR as there's too much feature creep going on

@akundaz akundaz closed this Apr 30, 2026
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