benchmarking flumelog-offset
In recent performance experiments, I started to realize that flumelog-offset
(the module that manages the main storage of messages in ssb has significant problems)
First I did tried creating a binary format optimized for in-place access and found reading and accessing a couple fields to be significantly faster than JSON parsing and entire record.
Next I tried using that as the codec in flumelog-offset
but I was disapointed to see that the improvement wasn't as much as just comparing it to JSON. Today I made a benchmark to test each layer in the offset format, to figure out where the slowness came from.
I discovered a couple things: block size makes a significant difference, and we weren't using a good blocksize (16k by default, should probably be 64k). Also, since we use JSON, that overwhelms the blocksize effect - we weren't noticing the effect of block size, because JSON was slowing it down even more.
But also: just reading the blocks is surprisingly slow! I think the log
(read records but don't parse) could be closer to blocks
.
That lead me to implementing simpler parser for flumelog-offset
flumelog-offset-parser and when used with the proposed binary format, is significantly faster
Note, the vertical axis is milliseconds - the difference is between waiting under 1 second to waiting 6 seconds.
Additional analysis at bench-flumelog-offset
all tests conducted on lenovo x201 with spinning disk, but warmed os fs cache.
The major TODO here, rewrite flumelog-offset for performance.
The time to scan the entire log file should be close to the time to just read the file. /cc @arj @C-Keen