This branch optimizes various prevector
operations, especially resizing vectors. While profiling the loadblk
thread I noticed that a lot of time was being spent in prevector::resize()
which led to this work. I have some data here indicating that it takes up 37% of the time in ReadBlockFromDisk()
: https://monad.io/readblockfromdisk.svg
This branch improves things significantly. For trivial types, the new results for the prevector benchmark are:
PrevectorClearTrivial
which testsprevector::clear()
becomes 24.6x fasterPrevectorDestructorTrivial
which testsprevector::~prevector()
becomes 20.5x fasterPrevectorResizeTrivial
which testsprevector::resize()
becomes 20.3x faster
Note that in practice it looks like the prevector is only used to contain unsigned char
types, which is a trivial type. The benchmarks are testing a bit of an extreme case, but the changes here are motivated by the profiling data for ReadBlockFromDisk()
I linked to above.
The pull request here consists of a series of three commits: