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

optimization: txpool pricedlist only reheap when pool is full #175

Merged
merged 2 commits into from
Oct 10, 2024

Conversation

andyzhang2023
Copy link
Contributor

Description

The pricedlist LegacyTxpool.priced is used to evict transactions when the pool overflows. It sorts all remote pending transactions by nonce and price and decides which transaction to stay and which to remove. It only works when the pool is full, but re-heap every second when the state of the pool changes.. The cost of re-heap is hight because it re-sorts all the pending transactions.

This improvement changes it to "only re-heap when the pool overflows", so that:

  1. LegacyTxpool.runReorg() cost less time to update the whole state of the pool.
  2. LegacyTxpool.Add() can be called more because it shares the mu.Lock with LegacyTxpool.runReorg()
  3. some other calls who share the mu.Lock too will get lower latency just as the LegacyTxpool.Add() does.

All of these will support higher TPS on the pool.

@owen-reorg owen-reorg changed the title txpool pricedlist only reheap when pool is full optimization: txpool pricedlist only reheap when pool is full Oct 10, 2024
@owen-reorg owen-reorg merged commit c1420cc into bnb-chain:develop Oct 10, 2024
2 checks passed
owen-reorg added a commit that referenced this pull request Oct 14, 2024
Co-authored-by: Owen <103096885+owen-reorg@users.noreply.github.com>
Co-authored-by: andyzhang2023 <andyzhang2023@gmail.com>
This was referenced Oct 14, 2024
welkin22 added a commit to welkin22/op-geth that referenced this pull request Oct 28, 2024
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.

3 participants