Enqueuing a transaction into the txpool, it costs about 80us per transaction to call txpool.Add(tx), within which the txpool.addLocked(tx) costs only 15us.
So by calling txpool.Add(tx) in parallel, we can improve the performance of txpool.Add(tx) from 12KTPS to 60KTPS:
before improvement: 1s/80us = 1000000/80 = 12500
after improvement: 1s/15us = 1000000/15 = 66666
It helps a lot when the traffic is heavy and a lot of transactions are accumulated in the broadcasting caches, like "p2p buffers", TCP read buffer and TCP write buffers.
Description
Enqueuing a transaction into the txpool, it costs about 80us per transaction to call
txpool.Add(tx)
, within which thetxpool.addLocked(tx)
costs only 15us. So by callingtxpool.Add(tx)
in parallel, we can improve the performance oftxpool.Add(tx)
from 12KTPS to 60KTPS:It helps a lot when the traffic is heavy and a lot of transactions are accumulated in the broadcasting caches, like "p2p buffers", TCP read buffer and TCP write buffers.