miner: skip loop processing and allocations for empty transaction events#2285
Open
shinobi133 wants to merge 4 commits into
Open
miner: skip loop processing and allocations for empty transaction events#2285shinobi133 wants to merge 4 commits into
shinobi133 wants to merge 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the miner worker’s transaction-event handling path in mainLoop to avoid doing work when a NewTxsEvent contains no transactions, aiming to reduce unnecessary processing/allocations in that case.
Changes:
- Adds an early exit when
ev.Txsis empty. - Introduces a parallel “sender cache warm-up” step for non-empty transaction batches before grouping transactions by sender.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+931
to
+948
| if len(ev.Txs) == 0 { | ||
| w.newTxs.Add(0) | ||
| continue | ||
| } | ||
|
|
||
| // Warm up cryptographic sender caches in parallel across cores | ||
| var wg sync.WaitGroup | ||
| for _, tx := range ev.Txs { | ||
| wg.Add(1) | ||
| go func(t *types.Transaction) { | ||
| defer wg.Done() | ||
| if w.current != nil { | ||
| types.Sender(w.current.signer, t) | ||
| } | ||
| }(tx) | ||
| } | ||
| wg.Wait() | ||
|
|
Member
|
@shinobi133 - please fix the CI and address the comments |
Comment on lines
+931
to
+949
| if len(ev.Txs) == 0 { | ||
| w.newTxs.Add(0) | ||
| continue | ||
| } | ||
|
|
||
| txs := make(map[common.Address][]*txpool.LazyTransaction) | ||
| for _, tx := range ev.Txs { | ||
| acc, _ := types.Sender(w.current.signer, tx) | ||
| txs[acc] = append(txs[acc], &txpool.LazyTransaction{ | ||
| Pool: w.eth.TxPool(), | ||
| Hash: tx.Hash(), | ||
| Tx: tx, | ||
| Time: tx.Time(), | ||
| GasFeeCap: uint256.MustFromBig(tx.GasFeeCap()), | ||
| GasTipCap: uint256.MustFromBig(tx.GasTipCap()), | ||
| Gas: tx.Gas(), | ||
| BlobGas: tx.BlobGas(), | ||
| }) | ||
| } |
… tx events without allocations
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
<one paragraph: what changed and why. If the change has measurable impact, add a small table or numbers (e.g. perf delta on a kurtosis devnet, mutation kill rate). Link the JIRA / GH issue inline if there is one — not required.>
Executed tests
<what was actually run beyond CI's standard unit / integration / e2e gates: kurtosis scenarios, chaos runs, manual checks against Amoy / mainnet RPCs, devnet upgrades, etc. Include output or pointers to where the run lives.>
Rollout notes
<consensus-affecting? requires coordinated upgrade? backwards-compatible? operator-facing change?>