Compare commits
2 Commits
1437280ec7
...
06fcb2531e
Author | SHA1 | Date | |
---|---|---|---|
06fcb2531e | |||
bd24a362e3 |
@@ -247,6 +247,19 @@ struct Node256 : Node {
|
|||||||
uint8_t *partialKey() { return (uint8_t *)(this + 1); }
|
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
|
// Bounds memory usage in free list, but does not account for memory for partial
|
||||||
// keys.
|
// keys.
|
||||||
template <class T, size_t kMemoryBound = (1 << 20)>
|
template <class T, size_t kMemoryBound = (1 << 20)>
|
||||||
@@ -332,8 +345,7 @@ uint8_t *Node::partialKey() {
|
|||||||
case Type::Node256:
|
case Type::Node256:
|
||||||
return ((Node256 *)this)->partialKey();
|
return ((Node256 *)this)->partialKey();
|
||||||
}
|
}
|
||||||
__builtin_unreachable();
|
__builtin_unreachable(); // GCOVR_EXCL_LINE
|
||||||
; // GCOVR_EXCL_LINE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct NodeAllocators {
|
struct NodeAllocators {
|
||||||
@@ -526,12 +538,6 @@ int getChildGeq(Node *self, int child) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setChildrenParents(Node4 *n) {
|
|
||||||
for (int i = 0; i < n->numChildren; ++i) {
|
|
||||||
n->children[i].child->parent = n;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void setChildrenParents(Node16 *n) {
|
void setChildrenParents(Node16 *n) {
|
||||||
for (int i = 0; i < n->numChildren; ++i) {
|
for (int i = 0; i < n->numChildren; ++i) {
|
||||||
n->children[i].child->parent = n;
|
n->children[i].child->parent = n;
|
||||||
|
Reference in New Issue
Block a user