commit d770ec9c90bb24af7f11d44a6aae10c8c012ff99
parent 0c3292bc0b6e9fa9db6a0042c373a7133b222516
Author: Randell Jesup <rjesup@mozilla.com>
Date: Wed, 22 Oct 2025 12:46:09 +0000
Bug 1995710: Don't purge dictionary cache entries r=necko-reviewers,valentin
Don't purge the metadata-only dictionary origin cache entries; when the
entries they refer to are deleted, the reference in the dictionary origin
cache entry will be removed
Differential Revision: https://phabricator.services.mozilla.com/D269559
Diffstat:
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/netwerk/cache2/CacheStorageService.cpp b/netwerk/cache2/CacheStorageService.cpp
@@ -1497,11 +1497,22 @@ Result<size_t, nsresult> CacheStorageService::MemoryPool::PurgeByFrecency(
StaticMutexAutoLock lock(CacheStorageService::Self()->Lock());
for (const auto& entry : mManagedEntries) {
- // Referenced items cannot be purged and we deliberately want to not look
- // at '0' frecency entries, these are new entries and can be ignored.
- if (!entry->IsReferenced() && entry->GetFrecency() > 0.0) {
+ // Referenced items cannot be purged and we deliberately want to not
+ // look at '0' frecency entries, these are new entries and can be
+ // ignored. Also, any dict: (CompressionDictionary) entries for an
+ // origin should not be purged unless empty - they will empty out as
+ // the cache entries referenced by them are purged until they are empty.
+ if (!entry->IsReferenced() && entry->GetFrecency() > 0.0 &&
+ (!entry->GetEnhanceID().EqualsLiteral("dict:") ||
+ entry->GetMetadataMemoryConsumption() == 0)) {
mayPurgeEntry copy(entry);
mayPurgeSorted.AppendElement(std::move(copy));
+ } else {
+ if (entry->GetEnhanceID().EqualsLiteral("dict:")) {
+ LOG_DICTIONARIES(
+ ("*** Entry is a dictionary origin, metadata size %d",
+ entry->GetMetadataMemoryConsumption()));
+ }
}
}
}