From 12540b8713622083e1a921c659c5dc817027fbd1 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Wed, 13 Mar 2024 14:00:01 -0700 Subject: [PATCH] maybeDecreaseCapacity policy was too strong We can allow larger capacities and still pay for the key bytes --- ConflictSet.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 76adb35..77880d2 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -292,9 +292,10 @@ static_assert(kNode3Surplus >= kMinNodeSurplus); static_assert(kBytesPerKey - sizeof(Node0) >= kMinNodeSurplus); // setOldestVersion will additionally try to maintain this property: -// `max(children, 1) * length >= capacity` +// `(children + entryPresent) * length >= capacity` // -// Which should give us the budget to pay for the key bytes +// Which should give us the budget to pay for the key bytes. (children + +// entryPresent) is a lower bound on how many keys these bytes are a prefix of template struct BoundedFreeListAllocator { @@ -910,7 +911,7 @@ void makeCapacityAtLeast(Node *&self, int capacity, NodeAllocators *allocators, void maybeDecreaseCapacity(Node *&self, NodeAllocators *allocators, ConflictSet::Impl *impl) { const int maxCapacity = - std::max(self->numChildren, 1) * self->partialKeyLen; + (self->numChildren + int(self->entryPresent)) * self->partialKeyLen; if (self->partialKeyCapacity <= maxCapacity) { return; }