]> git.ipfire.org Git - thirdparty/squid.git/commit - src/Transients.cc
Stop wasting 96 RAM bytes per slot for high-offset slots in large shared caches
authorAlex Rousskov <rousskov@measurement-factory.com>
Mon, 21 Apr 2014 18:09:06 +0000 (12:09 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Mon, 21 Apr 2014 18:09:06 +0000 (12:09 -0600)
commit1860fbac93c9da43094bf7c49ebcb7d22db60ed6
treeec3b61469b90b0bbea555657267964ba0ddb001a
parent557e770f1bccad7dc24b11df0acd402952ec7068
Stop wasting 96 RAM bytes per slot for high-offset slots in large shared caches
with more than 16777216 slots.

Ipc::StoreMap was using the same structure for all db slots. However, slots at
offsets exceeding SwapFilenMax (16777215) could not contain store entry
anchors and the anchor part of the structure was wasting RAM for those slots.
This change splits a single array of StoreMapSlots into two arrays, one
storing StoreMapAnchors and one storing StoreMapSlices. The anchors array is
shorter for caches with more than 16777216 slots.

For example, a StoreMap for a 1TB shared cache with default 16KB slot sizes
(67108864 slots) occupied about 6.5GB of RAM. After this change, the same
information is stored in about 2.0GB because unused anchors are not stored.

32-bit environments were wasting 72 (instead of 96) bytes per high-offset slot.

Also simplified Ipc::StoreMap API by removing its StoreMapWithExtras part.
The added complexity caused bugs and was not worth saving a few extra lines of
callers code. With the StoreMap storage array split in two, the extras may
belong to each part (although the current code only adds extras to slices),
further complicating the WithExtras part of the StoreMap API. These extras
are now stored in dedicated shared memory segments (*_ex.shm).

Added Ipc::Mem::Segment::Name() function to standardize segment name
formation.  TODO: Attempt to convert shm_new/old API to use SBuf instead of
char* to simplify callers, most of which have to form Segment IDs by
concatenating strings.
src/MemStore.cc
src/MemStore.h
src/Transients.cc
src/Transients.h
src/fs/rock/RockSwapDir.cc
src/fs/rock/RockSwapDir.h
src/ipc/StoreMap.cc
src/ipc/StoreMap.h
src/ipc/mem/Segment.cc
src/ipc/mem/Segment.h