Skip to content

perf(builder): boilerplate of prewarming for best transactions#3865

Merged
joshieDo merged 21 commits into
mainfrom
alexey/add-payload-prewarming
May 18, 2026
Merged

perf(builder): boilerplate of prewarming for best transactions#3865
joshieDo merged 21 commits into
mainfrom
alexey/add-payload-prewarming

Conversation

@shekhirin
Copy link
Copy Markdown
Member

@shekhirin shekhirin commented May 8, 2026

Adds an opt-in --builder.enable-prewarming flag that enables prewarming thread that consumes best_txs at its own speed, and buffers transactions for payload building to consume. Prewarming accounts for invalidations for buffered transactions.

This PR doesn't do any prewarming yet, next step would be to start executing transactions on top of latest state and populating shared cache.

The flag is disabled by default, so existing payload building behavior is unchanged.

@shekhirin shekhirin changed the title refactor(payload): stream best txs into the builder feat(builder): stream best txs into the builder May 8, 2026
@shekhirin shekhirin force-pushed the alexey/add-payload-prewarming branch 3 times, most recently from c39065e to 1908417 Compare May 8, 2026 16:17
@shekhirin shekhirin changed the title feat(builder): stream best txs into the builder perf(builder): prewarming boilerplate May 8, 2026
@shekhirin shekhirin added C-perf A change motivated by improving speed, memory usage or disk footprint A-block-building Related to block building labels May 8, 2026
@shekhirin shekhirin force-pushed the alexey/add-payload-prewarming branch from 69ad1ba to 775e11a Compare May 8, 2026 18:58
@shekhirin shekhirin changed the title perf(builder): prewarming boilerplate perf(builder): prewarm best transactions May 8, 2026
@shekhirin shekhirin changed the title perf(builder): prewarm best transactions perf(builder): prewarming ofr best transactions May 8, 2026
@shekhirin shekhirin changed the title perf(builder): prewarming ofr best transactions perf(builder): prewarming for best transactions May 8, 2026
@shekhirin shekhirin force-pushed the alexey/add-payload-prewarming branch 2 times, most recently from 0540f20 to f781c0a Compare May 8, 2026 19:05
@shekhirin shekhirin force-pushed the alexey/add-payload-prewarming branch from f781c0a to 85b849a Compare May 11, 2026 10:10
@shekhirin shekhirin force-pushed the alexey/add-payload-prewarming branch from 749d3ad to a742511 Compare May 11, 2026 11:07
@shekhirin shekhirin force-pushed the alexey/add-payload-prewarming branch from 37172c1 to 99aec0d Compare May 11, 2026 12:25
@shekhirin shekhirin force-pushed the alexey/add-payload-prewarming branch from 99aec0d to c0add3f Compare May 11, 2026 12:27
@shekhirin shekhirin marked this pull request as ready for review May 11, 2026 12:27
@shekhirin shekhirin changed the title perf(builder): prewarming for best transactions perf(builder): boilerplate of prewarming for best transactions May 11, 2026
Comment on lines +46 to +65
loop {
if let Some(tx) = ctx.best_txs.next() {
if ctx
.events_tx
.send(BestTransactionsEvent::Transaction(tx))
.is_err()
{
break;
}

// TODO: prewarm state by executing the transaction `tx` on top of latest state
} else {
// No more best transactions for now. We do not break the loop,
// because there may be more transactions later.
if ctx.events_tx.send(BestTransactionsEvent::Empty).is_err() {
break;
}
}

while let Ok(command) = ctx.commands_rx.try_recv() {
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.

this would effectively hotloop until entire iterator is drained right? i guess maybe it's fine because we're just draining Arcs but we could probably change this so that the builder thread directly requests new transactions via something like BestTransactionsCommand::Advance(oneshot::Receiver)

in practice most of the time prewarming should be ahead so the buffer of transactions we've drained for prewarming workers should be enough for execution to advance, so it shouldn't be necessary to drain the entire iter

@joshieDo joshieDo enabled auto-merge May 18, 2026 21:58
@joshieDo joshieDo added this pull request to the merge queue May 18, 2026
Merged via the queue into main with commit 506cfc2 May 18, 2026
40 checks passed
@joshieDo joshieDo deleted the alexey/add-payload-prewarming branch May 18, 2026 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-block-building Related to block building 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.

3 participants