Skip to content

Commit ba0e591

Browse files
committed
Slightly simplified bshrub commit estimate calculation
At the cost of a bit more frequent estimate scans. Saves a tiny bit of code: code stack ctx before: 36300 2576 640 after: 36280 (-0.1%) 2576 (+0.0%) 640 (+0.0%)
1 parent b9aaeab commit ba0e591

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

lfs.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6282,12 +6282,7 @@ static int lfsr_bshrub_commit_(lfs_t *lfs, lfsr_bshrub_t *bshrub,
62826282
// figure out how much data this commit progs
62836283
lfs_size_t commit_estimate = 0;
62846284
for (lfs_size_t i = 0; i < rat_count; i++) {
6285-
// only include tag overhead if tag is not a grow/rm tag
6286-
if (!lfsr_tag_isgrow(rats[i].tag)
6287-
&& !lfsr_tag_isrm(rats[i].tag)) {
6288-
commit_estimate += lfs->rat_estimate;
6289-
}
6290-
commit_estimate += lfsr_rat_size(rats[i]);
6285+
commit_estimate += lfs->rat_estimate + lfsr_rat_size(rats[i]);
62916286
}
62926287

62936288
// does our estimate exceed our shrub_size? need to recalculate an
@@ -6302,8 +6297,8 @@ static int lfsr_bshrub_commit_(lfs_t *lfs, lfsr_bshrub_t *bshrub,
63026297
}
63036298

63046299
// two cases where we evict:
6305-
// - overlow shrub_size/2 - don't penalize for commits here
6306-
// - overlow shrub_size - must include commits or we risk overflow
6300+
// - overflow shrub_size/2 - don't penalize for commits here
6301+
// - overflow shrub_size - must include commits or we risk overflow
63076302
//
63086303
// the 1/2 here prevents runaway performance with the shrub is
63096304
// near full, but it's a heuristic, so including the commit would

0 commit comments

Comments
 (0)