Skip to content

Commit

Permalink
Avoid MANIFEST_TREE_CACHE growing indefinitely during changeset impor…
Browse files Browse the repository at this point in the history
…t phase
  • Loading branch information
glandium committed Nov 13, 2023
1 parent 3a0c5bf commit 90c324a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/cinnabar/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ impl GitManifestTree {
let queries_limit = cmp::max(100, lru_cache.len() / 2);
if *queries >= queries_limit {
let miss_rate = *misses / (*queries / 10);
if (lru_cache.cap() == NonZeroUsize::MAX) || miss_rate >= 7 {
// Avoid growing the cache when we're flat-lining at 100% miss rate.
if (lru_cache.cap() == NonZeroUsize::MAX) || (miss_rate >= 7 && *misses != *queries)
{
lru_cache.resize(
NonZeroUsize::new(lru_cache.len() + lru_cache.len() / 2 + 1).unwrap(),
);
Expand Down

0 comments on commit 90c324a

Please sign in to comment.