Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're going to do this we should add log entries around this so that we get some idea of how long this is taking in the wild. As I said in chat I think this pessimizes the first query which is our hardest to make fast. We should schedule this later, maybe after the first snapshot has been delivered?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect (especially given @var-const s recent performance improvements) we can likely abandon this PR and not (manually) compact the database; leveldb should be taking care of this for us automatically. There's certainly some cases where that doesn't immediately happen, but I suspect they're corner cases. They may be worth pursing anyway; but I'd prefer to do so only if we still observe slowness (due to an uncompacted db) after Costa's changes hit.
And yes, if we do decide to pursue this, doing so before the first query seems sub-optimal. I suspect if we could schedule this after all (large?) queries complete when the db is otherwise idle, we'd get the same improvement without penalizing first query.