Commit 545087ef authored by Oded Arbel's avatar Oded Arbel
Browse files

WIP: Initial heuristic for determining automatic compaction

(`balooctl compact` always forces)
- If it won't save at least 200MB, don't bother
- Compact if database is 50% empty, or wasting more than 2GB

These numbers are based on my system, which IMO is on the large size in
terms of user file count (~3M) but not huge, where common used index space
is ~950MB. I believe larger systems can see large gains (a few gigabytes)
per compaction operation, but should probably not do that more than once
a day or sth.
parent 0c9726df
Pipeline #59726 passed with stage
in 3 minutes and 18 seconds
......@@ -273,7 +273,12 @@ bool Database::compact(bool force)
}
// Check if compaction is actually needed
if (!force && dbsize.expectedSize * 1.5 > dbsize.actualSize) { // allow up to 33% wasted space
uint64_t freeableBytes = dbsize.actualSize - dbsize.expectedSize;
double percentUsed = dbsize.expectedSize / dbsize.actualSize;
bool shouldCompact = freeableBytes > 200000000L /* 200MB */ && (
freeableBytes > 2000000000L /* 2GB */ || percentUsed < 0.5
);
if (!force && !shouldCompact) {
qCInfo(ENGINE) << "Not compacting database due to insufficient expected gains";
return true;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment