The number of files definitely makes a difference. Badger picks up an index from each SST file, which looks like it is being done serially, so it takes time.
Maybe we could look into reading these tables concurrently, and see if that makes a difference.
Could you share the output of badger info here, so I can try and replicate your setup? Also, a list of your options, unless you’re using DefaultOptions.
But for some time I was using DefaultOptions only. I later changed LevelOneSize, MaxTableSize, ValueLogFileSize and ValueLogMaxEntries in an attempt to reduce the number of files.
If it helps, my use case here is storing log lines. Each line has a 16 bytes key (a ULID) while the value has arbitrary length.
What are the disadvantages of using bigger tables and/or value logs (if any) ?
This branch tries to make opening tables concurrent. However, in my tests with this external rotational HDD, the process was slower, because random seeks are slow. If you have an SSD, can you try with this branch and report back? @vrischmann
This branch also added logs to show how table opening is going on.
badger 2019/01/10 14:03:57 INFO: All 397 tables opened in 3m0.336s
it’s already a substantial gain in my case so that’s great.
While opening the database I’ve seen reads top at around 700mib/s but this array is capable of reading at more than 1gib/s (with a straight cat foo > /dev/null) so I’m not sure if I’m being i/o bound right now.
Here’s the graph of disk throughput, the blue line is the raid array (negative means reads).
Forgot to mention, I profiled my app with pprof while opening so I have a pprof cpu profile available if you’d like. I’d prefer to share it privately however since I’m not sure what sort of private data is included in it.
I think my latest changes improves opening performance significantly. Can you try again with my branch? mrjn/try-to-speed-open.
Weird error, not sure why it’s happening, i.e. why are tables having overlaps. Will have to look at the commit history to see if something changed recently.
We did a lot of testing with this change on various devices: rotational HDD, slower SSD, and faster SATA SSD. We see disk utilization is pretty good with these changes.