commit defcbb1ecba2df50bd011c727ada0109310b3bc4
parent 805e20dc6982730d34747ec9b564590a1e8fea66
Author: Randell Jesup <rjesup@mozilla.com>
Date: Wed, 1 Oct 2025 18:45:54 +0000
Bug 1917963: Add Cache flags for Compression Dictionaries r=necko-reviewers,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D258120
Diffstat:
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/netwerk/cache2/CacheIndex.h b/netwerk/cache2/CacheIndex.h
@@ -90,8 +90,9 @@ struct CacheIndexRecord {
* 0000 1000 0000 0000 0000 0000 0000 0000 : fresh
* 0000 0100 0000 0000 0000 0000 0000 0000 : pinned
* 0000 0010 0000 0000 0000 0000 0000 0000 : has cached alt data
- * 0000 0001 0000 0000 0000 0000 0000 0000 : reserved
+ * 0000 0001 0000 0000 0000 0000 0000 0000 : is a dictionary
* 0000 0000 1111 1111 1111 1111 1111 1111 : file size (in kB)
+ * Max file size is 16GiB
*/
uint32_t mFlags{0};
@@ -99,6 +100,16 @@ struct CacheIndexRecord {
};
#pragma pack(pop)
+// For Compression Dictionaries, we make special entries in the cache for
+// each origin with a dictionary. In the data or metadata for each of
+// these entries, we store the hashes of the dictionary, the match value
+// (required), the match-dest value (optional), the id (optional) and the
+// type (optional).
+
+// We mark an entry if it's a dictionary (use-as-dictionary); if it is,
+// when the entry is removed, we remove it from the origin's dictionary
+// entry. If the origin's dictionary list is empty, we remove the origin.
+
static_assert(sizeof(CacheIndexRecord::mHash) +
sizeof(CacheIndexRecord::mFrecency) +
sizeof(CacheIndexRecord::mOriginAttrsHash) +
@@ -378,9 +389,11 @@ class CacheIndexEntry : public PLDHashEntryHdr {
// Indicates there is cached alternative data in the entry.
static const uint32_t kHasAltDataMask = 0x02000000;
- static const uint32_t kReservedMask = 0x01000000;
- // FileSize in kilobytes
+ // Indicates that this entry is a dictionary
+ static const uint32_t kDictionaryMask = 0x01000000;
+
+ // FileSize in kilobytes (max 16GB)
static const uint32_t kFileSizeMask = 0x00FFFFFF;
RefPtr<CacheIndexRecordWrapper> mRec;