commit a85f97ac8c0de6f0e88a0996a27bee311ad297a1
parent 780bddc9453d9837862c57e653ba56fc2fa71e94
Author: Randell Jesup <rjesup@mozilla.com>
Date: Tue, 7 Oct 2025 14:07:08 +0000
Bug 1978496: Add more logs for Compression Dictionaries r=necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D262695
Diffstat:
3 files changed, 37 insertions(+), 11 deletions(-)
diff --git a/netwerk/cache2/CacheFileContextEvictor.cpp b/netwerk/cache2/CacheFileContextEvictor.cpp
@@ -660,8 +660,8 @@ void CacheFileContextEvictor::EvictEntries() {
// this must be a new one. Skip it.
LOG(
("CacheFileContextEvictor::EvictEntries() - Skipping entry since we "
- "found an active handle. [handle=%p]",
- handle.get()));
+ "found an active handle. [handle=%p key=%s]",
+ handle.get(), handle->Key().get()));
continue;
}
diff --git a/netwerk/cache2/Dictionary.cpp b/netwerk/cache2/Dictionary.cpp
@@ -847,7 +847,7 @@ nsresult DictionaryCache::RemoveEntry(nsIURI* aURI, const nsACString& aKey) {
if (NS_FAILED(GetDictPath(aURI, prepath))) {
return NS_ERROR_FAILURE;
}
- DICTIONARY_LOG(("Dictionary RemoveEntry for %s : %s", prepath.get(),
+ DICTIONARY_LOG(("DictionaryCache::RemoveEntry for %s : %s", prepath.get(),
PromiseFlatCString(aKey).get()));
if (auto origin = mDictionaryCache.Lookup(prepath)) {
return origin.Data()->RemoveEntry(aKey);
@@ -1170,6 +1170,7 @@ nsresult DictionaryOrigin::RemoveEntry(const nsACString& aKey) {
if (dict->GetURI().Equals(aKey)) {
// Ensure it doesn't disappear on us
RefPtr<DictionaryCacheEntry> hold(dict);
+ DICTIONARY_LOG(("Removing %p", dict.get()));
mEntries.RemoveElement(dict);
if (mEntry) {
hold->RemoveEntry(mEntry);
@@ -1178,10 +1179,6 @@ nsresult DictionaryOrigin::RemoveEntry(const nsACString& aKey) {
// the entry until we do
mPendingRemove.AppendElement(hold);
}
- if (MOZ_UNLIKELY(
- MOZ_LOG_TEST(gDictionaryLog, mozilla::LogLevel::Debug))) {
- DumpEntries();
- }
return NS_OK;
}
}
@@ -1191,12 +1188,9 @@ nsresult DictionaryOrigin::RemoveEntry(const nsACString& aKey) {
if (dict->GetURI().Equals(aKey)) {
// Ensure it doesn't disappear on us
RefPtr<DictionaryCacheEntry> hold(dict);
+ DICTIONARY_LOG(("Removing %p", dict.get()));
mPendingEntries.RemoveElement(dict);
hold->RemoveEntry(mEntry);
- if (MOZ_UNLIKELY(
- MOZ_LOG_TEST(gDictionaryLog, mozilla::LogLevel::Debug))) {
- DumpEntries();
- }
return NS_OK;
}
}
@@ -1210,6 +1204,10 @@ void DictionaryOrigin::FinishAddEntry(DictionaryCacheEntry* aEntry) {
// have an equivalent match length (and dest)
mEntries.InsertElementAt(0, aEntry);
}
+ DICTIONARY_LOG(("FinishAddEntry(%s)", aEntry->mURI.get()));
+ if (MOZ_UNLIKELY(MOZ_LOG_TEST(gDictionaryLog, mozilla::LogLevel::Debug))) {
+ DumpEntries();
+ }
}
void DictionaryOrigin::RemoveEntry(DictionaryCacheEntry* aEntry) {
@@ -1222,6 +1220,31 @@ void DictionaryOrigin::RemoveEntry(DictionaryCacheEntry* aEntry) {
}
}
+void DictionaryOrigin::DumpEntries() {
+ DICTIONARY_LOG(("*** Origin %s ***", mOrigin.get()));
+ for (const auto& dict : mEntries) {
+ DICTIONARY_LOG(
+ ("* %s: pattern %s, id %s, match-dest[0]: %s, hash: %s, expiration: "
+ "%u",
+ dict->mURI.get(), dict->mPattern.get(), dict->mId.get(),
+ dict->mMatchDest.IsEmpty()
+ ? ""
+ : dom::GetEnumString(dict->mMatchDest[0]).get(),
+ dict->mHash.get(), dict->mExpiration));
+ }
+ DICTIONARY_LOG(("*** Pending ***"));
+ for (const auto& dict : mPendingEntries) {
+ DICTIONARY_LOG(
+ ("* %s: pattern %s, id %s, match-dest[0]: %s, hash: %s, expiration: "
+ "%u",
+ dict->mURI.get(), dict->mPattern.get(), dict->mId.get(),
+ dict->mMatchDest.IsEmpty()
+ ? ""
+ : dom::GetEnumString(dict->mMatchDest[0]).get(),
+ dict->mHash.get(), dict->mExpiration));
+ }
+}
+
void DictionaryOrigin::Clear() {
mEntries.Clear();
mPendingEntries.Clear();
diff --git a/netwerk/cache2/Dictionary.h b/netwerk/cache2/Dictionary.h
@@ -48,6 +48,8 @@ class DictionaryOrigin;
// initially until the full data has arrived, then update the Hash.
class DictionaryCacheEntry final : public nsICacheEntryOpenCallback,
public nsIStreamListener {
+ friend class DictionaryOrigin;
+
private:
~DictionaryCacheEntry() { MOZ_ASSERT(mUsers == 0); }
@@ -279,6 +281,7 @@ class DictionaryOrigin : public nsICacheEntryMetaDataVisitor {
DictionaryCacheEntry* Match(const nsACString& path,
ExtContentPolicyType aType);
void FinishAddEntry(DictionaryCacheEntry* aEntry);
+ void DumpEntries();
void Clear();
private: