Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
valblk: fix Writer.Size() performance
`Writer.Size()` unnecessarily loops through all the blocks instead of using `totalBlockBytes`. This seems like an oversight: we only append to `blocks` in `compressAndFlush` where we also update `totalBlockBytes`. I verified that in all Pebble tests these values are the same, using `if sz != w.totalBlockBytes { panic() }`. ``` name old time/op new time/op delta WriterWithVersions/vals-per-key=1/format=(Pebble,v5)/block=32KB/filter=false/compression=NoCompression 77.2ms ± 1% 76.6ms ± 0% -0.70% (p=0.008 n=5+5) WriterWithVersions/vals-per-key=10/format=(Pebble,v5)/block=32KB/filter=false/compression=NoCompression 752ms ± 0% 99ms ± 1% -86.83% (p=0.008 n=5+5) WriterWithVersions/vals-per-key=10000/format=(Pebble,v5)/block=32KB/filter=false/compression=NoCompression 908ms ± 0% 103ms ± 0% -88.64% (p=0.008 n=5+5) name old speed new speed delta WriterWithVersions/vals-per-key=1/format=(Pebble,v5)/block=32KB/filter=false/compression=NoCompression 462MB/s ± 1% 466MB/s ± 0% +0.70% (p=0.008 n=5+5) WriterWithVersions/vals-per-key=10/format=(Pebble,v5)/block=32KB/filter=false/compression=NoCompression 53.0MB/s ± 0% 402.7MB/s ± 1% +659.47% (p=0.008 n=5+5) WriterWithVersions/vals-per-key=10000/format=(Pebble,v5)/block=32KB/filter=false/compression=NoCompression 49.1MB/s ± 0% 431.8MB/s ± 0% +780.16% (p=0.008 n=5+5) ```
- Loading branch information