Skip to content
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

perf: warm transactions in parallel #13759

Merged
merged 1 commit into from
Feb 4, 2025
Merged

perf: warm transactions in parallel #13759

merged 1 commit into from
Feb 4, 2025

Conversation

Rjected
Copy link
Member

@Rjected Rjected commented Jan 9, 2025

This spawns tx prewarm threads on a dedicated threadpool, similar to the state root task threadpool

ref #13713

@Rjected Rjected added C-enhancement New feature or request C-perf A change motivated by improving speed, memory usage or disk footprint A-execution Related to the Execution and EVM labels Jan 9, 2025
);

// TODO: move this logic somewhere better?
for tx in block.body().transactions() {
Copy link
Member

Choose a reason for hiding this comment

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

you could wrap the entire thing in pool.scope(|s| ) to avoid cloning but then it would block at scope end

Copy link
Member Author

Choose a reason for hiding this comment

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

scoping could be useful because we will need to make sure all tasks are complete when we are doing cross-block caching + prewarming (basically using scope as a waitgroup). But I think it would make this fn body a bit of a mess, and we could accomplish a similar thing by using a RwLock

@Rjected Rjected force-pushed the dan/parallel-warming branch 11 times, most recently from 0d6178c to 97fd66a Compare January 23, 2025 20:37
@Rjected Rjected force-pushed the dan/parallel-warming branch 14 times, most recently from 034e958 to 1c3d657 Compare January 31, 2025 00:12
@Rjected Rjected force-pushed the dan/parallel-warming branch 3 times, most recently from 8310175 to 404b30e Compare January 31, 2025 19:17
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

nits, otherwise lgtm

Copy link
Collaborator

Choose a reason for hiding this comment

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

fyi @klkvr likely conflicts with revm integration wip

};

// if execution is finished there is no point to sending proof targets
if execution_finished.load(std::sync::atomic::Ordering::SeqCst) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

we have this a few times,

we could duplicate this

pub struct Cancelled(Arc<AtomicBool>);

or import if in scope or move to somewhere shared

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah adding somewhere else and sharing makes sense

Copy link
Member Author

Choose a reason for hiding this comment

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

moved to reth_revm, now reused in both places

// the block leads back to the canonical chain
let historical = self.provider.state_by_block_hash(historical)?;
return Ok(Some(Box::new(MemoryOverlayStateProvider::new(historical, blocks))))
}

// the hash could belong to an unknown block or a persisted block
if let Some(header) = self.provider.header(&hash)? {
debug!(target: "engine::tree", %hash, number = %header.number(), "found canonical state for block in database");
debug!(target: "engine::tree", ?hash, number = ?header.number(), "found canonical state for block in database");
Copy link
Member

Choose a reason for hiding this comment

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

Why change to Debug? you should generally always prefer Display (%)

Copy link
Member Author

Choose a reason for hiding this comment

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

whoops, artifact from when i removed these logs since they were weirdly showing up as taking a lot of time in some profiles

let ResultAndState { state, .. } = match evm.transact(tx_env) {
Ok(res) => res,
Err(err) => {
error!(target: "engine::tree", ?err, tx_hash=?tx.tx_hash(), ?sender, "Error when executing prewarm transaction");
Copy link
Member

Choose a reason for hiding this comment

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

isn't error! too verbose here? also same as last comment

Copy link
Member Author

@Rjected Rjected Feb 2, 2025

Choose a reason for hiding this comment

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

yeah, will change to trace or debug

@Rjected Rjected force-pushed the dan/parallel-warming branch 2 times, most recently from 0cc94b1 to 41774d3 Compare February 2, 2025 18:55
@Rjected Rjected force-pushed the dan/parallel-warming branch from 41774d3 to 8dc62b5 Compare February 3, 2025 23:05
@Rjected Rjected requested a review from rakita as a code owner February 3, 2025 23:05
@Rjected Rjected force-pushed the dan/parallel-warming branch from 8dc62b5 to 4d0345e Compare February 3, 2025 23:05
@Rjected Rjected requested a review from mattsse February 3, 2025 23:10
@Rjected Rjected force-pushed the dan/parallel-warming branch 2 times, most recently from 08000b7 to eacc83a Compare February 3, 2025 23:22
@Rjected Rjected force-pushed the dan/parallel-warming branch from eacc83a to af9a8a6 Compare February 3, 2025 23:39
@jenpaff jenpaff requested review from fgimenez and DaniPopes February 4, 2025 08:45
Copy link
Member

@fgimenez fgimenez left a comment

Choose a reason for hiding this comment

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

lgtm!

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm

@Rjected Rjected added this pull request to the merge queue Feb 4, 2025
Merged via the queue into main with commit b6ce1d9 Feb 4, 2025
44 checks passed
@Rjected Rjected deleted the dan/parallel-warming branch February 4, 2025 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-execution Related to the Execution and EVM C-enhancement New feature or request C-perf A change motivated by improving speed, memory usage or disk footprint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants