From 06fcb2531edbb040aa15e5506109511d377f7c10 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Fri, 8 Mar 2024 17:04:22 -0800 Subject: [PATCH] Add an analysis on memory usage in static asserts CC #9 --- ConflictSet.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 891320b..1f3843b 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -247,6 +247,19 @@ struct Node256 : Node { uint8_t *partialKey() { return (uint8_t *)(this + 1); } }; +// Bound memory usage following the analysis in the ART paper + +constexpr int kBytesPerKey = 86; +constexpr int kMinChildrenNode4 = 2; +constexpr int kMinChildrenNode16 = 5; +constexpr int kMinChildrenNode48 = 17; +constexpr int kMinChildrenNode256 = 49; + +static_assert(sizeof(Node256) < kMinChildrenNode256 * kBytesPerKey); +static_assert(sizeof(Node48) < kMinChildrenNode48 * kBytesPerKey); +static_assert(sizeof(Node16) < kMinChildrenNode16 * kBytesPerKey); +static_assert(sizeof(Node4) < kMinChildrenNode4 * kBytesPerKey); + // Bounds memory usage in free list, but does not account for memory for partial // keys. template