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:
LegacyTxpool.runReorg() cost less time to update the whole state of the pool.
LegacyTxpool.Add() can be called more because it shares the mu.Lock with LegacyTxpool.runReorg()
some other calls who share the mu.Lock too will get lower latency just as the LegacyTxpool.Add() does.
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:
LegacyTxpool.runReorg()
cost less time to update the whole state of the pool.LegacyTxpool.Add()
can be called more because it shares the mu.Lock withLegacyTxpool.runReorg()
LegacyTxpool.Add()
does.All of these will support higher TPS on the pool.