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

core: more efficient nonce-update in txpool #22231

Merged
merged 3 commits into from
Nov 2, 2021
Merged

Conversation

holiman
Copy link
Contributor

@holiman holiman commented Jan 25, 2021

This PR supersedes #21164 by @WeiLoy . The original PR was based off a fork of geth but on master , and I was not able to push the rebased + fixed version onto a master branch.

I believe that the original implementation by @WeiLoy was correct, but it had been a bit bitrotted, the PR is quite old.
Here are the benchmarks compared to current master:

benchstat before.txt after3.txt 
name                           old time/op  new time/op  delta
PoolMultiAccountBatchInsert-6   993µs ±11%   281µs ± 7%  -71.72%  (p=0.008 n=5+5)

@holiman
Copy link
Contributor Author

holiman commented Jan 26, 2021

Pushed a fix to make the benchmarks call the ..Sync methods. Stats basically the same:

name                           old time/op  new time/op  delta
PoolMultiAccountBatchInsert-6  1.61ms ±15%  0.35ms ± 9%  -78.14%  (p=0.008 n=5+5)

@MariusVanDerWijden
Copy link
Member

@holiman this looks pretty good, should we rebase and merge it?

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method
@holiman
Copy link
Contributor Author

holiman commented Oct 29, 2021

@MariusVanDerWijden yes, I'd almost forgotten about this. Rebased, ptal

@@ -77,3 +77,11 @@ func (txn *txNoncer) setIfLower(addr common.Address, nonce uint64) {
}
txn.nonces[addr] = nonce
}

// resetAll sets the nonces for all accounts to the given map.
func (txn *txNoncer) resetAll(all map[common.Address]uint64) {
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps call it setAll, since it doesn't really reset it.

core/tx_pool.go Outdated
@@ -1182,16 +1182,18 @@ func (pool *TxPool) runReorg(done chan struct{}, reset *txpoolResetRequest, dirt
pendingBaseFee := misc.CalcBaseFee(pool.chainconfig, reset.newHead)
pool.priced.SetBaseFee(pendingBaseFee)
}
// Update all accounts to the latest known pending nonce
nonces := make(map[common.Address]uint64)
Copy link
Member

Choose a reason for hiding this comment

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

If we want to ensure allocs are low, add len(pool.pending) to the end of the map make

@karalabe
Copy link
Member

karalabe commented Nov 2, 2021

Pls add the allocs to the benchmark, just as sanity

@fjl fjl removed the status:triage label Nov 2, 2021
Copy link
Contributor

@fjl fjl left a comment

Choose a reason for hiding this comment

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

I think this is OK, and may even resolve some consistency bugs in nonce management.

@holiman
Copy link
Contributor Author

holiman commented Nov 2, 2021

name                           old time/op    new time/op    delta
PoolMultiAccountBatchInsert-6     930µs ±11%     313µs ± 7%  -66.35%  (p=0.008 n=5+5)

name                           old alloc/op   new alloc/op   delta
PoolMultiAccountBatchInsert-6    19.0kB ± 9%    19.7kB ± 8%     ~     (p=0.222 n=5+5)

name                           old allocs/op  new allocs/op  delta
PoolMultiAccountBatchInsert-6      95.6 ± 5%      92.4 ± 4%     ~     (p=0.063 n=5+5)

@holiman holiman added this to the 1.10.12 milestone Nov 2, 2021
@holiman holiman merged commit 03bc8b7 into ethereum:master Nov 2, 2021
sidhujag pushed a commit to syscoin/go-ethereum that referenced this pull request Nov 3, 2021
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
@holiman holiman deleted the weiloyfix branch November 10, 2021 18:32
yongjun925 pushed a commit to DODOEX/go-ethereum that referenced this pull request Dec 3, 2022
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Sep 2, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Sep 6, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Sep 9, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Sep 9, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Sep 9, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Sep 10, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Sep 12, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Sep 12, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Sep 19, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Sep 19, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Sep 19, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Sep 21, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Sep 22, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Sep 22, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Sep 23, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Sep 23, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Sep 26, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Sep 26, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Sep 27, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Oct 9, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Oct 17, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Oct 18, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Oct 25, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Oct 25, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Oct 29, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Oct 30, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Oct 31, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Oct 31, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Nov 1, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
wanwiset25 pushed a commit to XinFinOrg/XDPoSChain that referenced this pull request Nov 13, 2024
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
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.

5 participants