-
Notifications
You must be signed in to change notification settings - Fork 20.4k
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
miner: avoid unnecessary work #15883
Conversation
Could you somehow measure the performance gain/loss? The miner inclusion code works per sender, not per transaction (since if a transaction is skipped, none of the subsequent ones from the same account can be executed either). As such, the inclusion logic is linear in accounts, not transactions. I don't see any problem in including this optimization in itself, but I'd really like to see some benchmarks put in place to put a number on them. My hunch is that it's negligible, but if not, I'd like to see the impact. |
I can give you some anecdotal information. Running on my local node (which is pretty beefy) and leaving out the optimisation I let it run for an while to obtain a decent number of transactions in the pool and see:
With the optimisation as per this PR I see:
|
And for the records the spec of the machine that these tests were run on: CPU: i7-4770 @ 3.4GHz |
Whoah |
At current the miner worker's
commitTransactions()
attempts to add every pending transaction from a transaction set in to the block. If a node has hundreds or thousands of pending transactions then the block quickly fills up but the loop continues to set up and run each of the remaining transactions even though they are guaranteed to fail.This patch adds a condition to the loop such that if the remaining gas in the pool falls below the base transaction cost i.e. is out of space then it breaks out of the loop, saving CPU and memory.