-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Storage Engines - Persistence
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Background
The victim block cache's underlying SizedLRUCache hardcodes an assumed average page size:
// TODO SERVER-121337: tune page size static constexpr std::size_t kPageSize = 4096;
(See src/mongo/db/modules/atlas/src/disagg_storage/pali/block_cache/sized_lru_cache.h.)
This constant is used only in setMaxSize() to pre-reserve hash-map buckets:
void setMaxSize(std::size_t maxSize) {
_maxSize = maxSize;
_map.reserve(maxSize / kPageSize);
}
The reservation estimates how many entries a shard will hold by dividing its byte budget by the assumed per-entry (page) size. The cache itself is sized and evicted by bytes, not by entry count, so kPageSize does not affect correctness — only the initial bucket count of the lookup map.
Problem
The 4096-byte assumption is a guess. If the actual average cached page size diverges from 4 KB:
- Pages larger than 4 KB → the map is over-reserved, wasting memory on unused buckets.
- Pages smaller than 4 KB → the map is under-reserved, causing rehashing as entries are inserted.
Proposed work
Tune the default kPageSize based on the average page size actually observed in the cache. This can be measured directly from serverStatus: blockCache.size / blockCache.count gives the live average entry size (both are captured in FTDC under serverStatus.blockCache.*). Pick a default that reflects representative workloads, and consider whether the value should be configurable rather than a compile-time constant.
- related to
-
SERVER-129289 Victim block cache size budget undercounts memory and can exceed maxSizeBytes hard cap
-
- Open
-