btcsuite / btcwallet

A secure bitcoin wallet daemon written in Go (golang)
ISC License
1.15k stars 590 forks source link

Optimize mempool maps #873

Closed yyforyongyu closed 1 year ago

yyforyongyu commented 1 year ago

Depends on #872, this PR removes a redundant Add(tx) for bitcoind ZMQ events, and optimized the memory usage of mempool based on the fact that, multiple inputs may share the same tx hash that leaves room for optimization.

yyforyongyu commented 1 year ago

Unfortunately the optimization doesn't work based pprof, will investigate more.

yyforyongyu commented 1 year ago

Replaced by #877 which focuses on removing the redundant Add. I don't think the maps in mempool can be optimized more, given most of the inputs don't share the same tx hash, and most spending txes are consuming inputs from different parent txes. Plus the space overhead of using nested maps, my pprof says it actually takes more space.