Skip to content

Compact the leveldb database on startup. #1494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

rsgowman
Copy link
Member

@rsgowman rsgowman commented Jul 4, 2018

No description provided.

@rsgowman
Copy link
Member Author

rsgowman commented Jul 4, 2018

It's not at all clear to me that this is the correct thing to do. It does seem to drastically speed up certain operations, but also note (from leveldb's docs): "This operation should typically only be invoked by users who understand the underlying implementation." That set of users does not include me.

This PR is being proposed as a discussion point, rather than the final suggested change.

@@ -209,6 +209,8 @@ - (nullable DB *)createDBWithDirectory:(NSString *)directory error:(NSError **)e
return nullptr;
}

database->CompactRange(nullptr, nullptr);
Copy link
Contributor

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?

Copy link
Member Author

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.

@wilhuff
Copy link
Contributor

wilhuff commented Jul 25, 2018

OK. We can reopen this later or do something similar at a later date if it's warranted.

@wilhuff wilhuff closed this Jul 25, 2018
@wilhuff
Copy link
Contributor

wilhuff commented Jul 25, 2018

The change in this branch is trivial, so you could reasonably delete this branch too, though it's not required.

@rsgowman rsgowman deleted the rsgowman/compact branch July 25, 2018 19:30
@firebase firebase locked and limited conversation to collaborators Oct 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants