diff options
| author | Stefan Boberg <[email protected]> | 2023-11-10 13:01:49 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-11-10 13:01:49 +0100 |
| commit | a6a2f7849557bb30b79dafb079ef0fc97736fd9f (patch) | |
| tree | 52c4419a4397bfd642d1c266d2303dd49124cfd4 /src | |
| parent | 0.2.31-pre2 (diff) | |
| download | zen-a6a2f7849557bb30b79dafb079ef0fc97736fd9f.tar.xz zen-a6a2f7849557bb30b79dafb079ef0fc97736fd9f.zip | |
reduce memory footprint for bucket indexes (#526)
reduces memory footprint of cache index by 10% or so by limiting the maximum number of entries in a bucket to 2^32 (was 2^64)
Diffstat (limited to 'src')
| -rw-r--r-- | src/zenserver/cache/cachedisklayer.h | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/zenserver/cache/cachedisklayer.h b/src/zenserver/cache/cachedisklayer.h index 99c54e192..4efdeebd7 100644 --- a/src/zenserver/cache/cachedisklayer.h +++ b/src/zenserver/cache/cachedisklayer.h @@ -233,11 +233,11 @@ private: #pragma pack(1) struct MetaDataIndex { - size_t Index = std::numeric_limits<size_t>::max(); + uint32_t Index = std::numeric_limits<uint32_t>::max(); - operator bool() const { return Index != std::numeric_limits<size_t>::max(); }; + operator bool() const { return Index != std::numeric_limits<uint32_t>::max(); }; MetaDataIndex() = default; - explicit MetaDataIndex(size_t Index) : Index(Index) {} + explicit MetaDataIndex(size_t InIndex) : Index(uint32_t(InIndex)) {} operator size_t() const { return Index; }; inline auto operator<=>(const MetaDataIndex& Other) const = default; }; @@ -248,32 +248,32 @@ private: operator bool() const { return Index != std::numeric_limits<uint32_t>::max(); }; MemCachedIndex() = default; - explicit MemCachedIndex(uint32_t Index) : Index(Index) {} + explicit MemCachedIndex(uint32_t InIndex) : Index(InIndex) {} operator size_t() const { return Index; }; inline auto operator<=>(const MemCachedIndex& Other) const = default; }; struct ReferenceIndex { - size_t Index = std::numeric_limits<size_t>::max(); + uint32_t Index = std::numeric_limits<uint32_t>::max(); - static const ReferenceIndex Unknown() { return ReferenceIndex{std::numeric_limits<size_t>::max()}; } - static const ReferenceIndex None() { return ReferenceIndex{std::numeric_limits<size_t>::max() - 1}; } + static const ReferenceIndex Unknown() { return ReferenceIndex{std::numeric_limits<uint32_t>::max()}; } + static const ReferenceIndex None() { return ReferenceIndex{std::numeric_limits<uint32_t>::max() - 1}; } ReferenceIndex() = default; - explicit ReferenceIndex(size_t Index) : Index(Index) {} + explicit ReferenceIndex(size_t InIndex) : Index(uint32_t(InIndex)) {} operator size_t() const { return Index; }; - operator bool() const { return Index != std::numeric_limits<size_t>::max(); }; + operator bool() const { return Index != std::numeric_limits<uint32_t>::max(); }; inline auto operator<=>(const ReferenceIndex& Other) const = default; }; struct PayloadIndex { - size_t Index = std::numeric_limits<size_t>::max(); + uint32_t Index = std::numeric_limits<uint32_t>::max(); - operator bool() const { return Index != std::numeric_limits<size_t>::max(); }; + operator bool() const { return Index != std::numeric_limits<uint32_t>::max(); }; PayloadIndex() = default; - explicit PayloadIndex(size_t Index) : Index(Index) {} + explicit PayloadIndex(size_t InIndex) : Index(uint32_t(InIndex)) {} operator size_t() const { return Index; }; inline auto operator<=>(const PayloadIndex& Other) const = default; }; @@ -281,7 +281,7 @@ private: struct BucketPayload { DiskLocation Location; // 12 - MetaDataIndex MetaData; // 8 + MetaDataIndex MetaData; // 4 MemCachedIndex MemCached; // 4 }; struct BucketMetaData @@ -292,7 +292,7 @@ private: operator bool() const { return RawSize != 0 || RawHash != IoHash::Zero; }; }; #pragma pack(pop) - static_assert(sizeof(BucketPayload) == 24u); + static_assert(sizeof(BucketPayload) == 20u); static_assert(sizeof(BucketMetaData) == 28u); static_assert(sizeof(AccessTime) == 4u); |