Fix nodes_released accounting
This commit is contained in:
@@ -1715,7 +1715,7 @@ void maybeDownsize(Node *self, WriteContext *tls, ConflictSet::Impl *impl,
|
||||
}
|
||||
}
|
||||
|
||||
void destroyTree(Node *root, int64_t *entriesErased) {
|
||||
void destroyTree(Node *root, WriteContext::Accum *accum) {
|
||||
Arena arena;
|
||||
auto toFree = vector<Node *>(arena);
|
||||
toFree.push_back(root);
|
||||
@@ -1730,7 +1730,8 @@ void destroyTree(Node *root, int64_t *entriesErased) {
|
||||
while (toFree.size() > 0) {
|
||||
auto *n = toFree.back();
|
||||
toFree.pop_back();
|
||||
*entriesErased += n->entryPresent;
|
||||
accum->entries_erased += n->entryPresent;
|
||||
++accum->nodes_released;
|
||||
|
||||
switch (n->getType()) {
|
||||
case Type_Node0: {
|
||||
@@ -1770,7 +1771,7 @@ void eraseBetween(Node3 *&n, int begin, int end, WriteContext *tls) {
|
||||
InternalVersionT *maxVOut = n->childMaxVersion;
|
||||
for (int i = 0; i < n->numChildren; ++i) {
|
||||
if (inBounds(n->index[i])) {
|
||||
destroyTree(n->children[i], &tls->accum.entries_erased);
|
||||
destroyTree(n->children[i], &tls->accum);
|
||||
} else {
|
||||
*nodeOut++ = n->children[i];
|
||||
*indexOut++ = n->index[i];
|
||||
@@ -1796,7 +1797,7 @@ void eraseBetween(Node16 *&n, int begin, int end, WriteContext *tls) {
|
||||
InternalVersionT *maxVOut = n->childMaxVersion;
|
||||
for (int i = 0; i < n->numChildren; ++i) {
|
||||
if (inBounds(n->index[i])) {
|
||||
destroyTree(n->children[i], &tls->accum.entries_erased);
|
||||
destroyTree(n->children[i], &tls->accum);
|
||||
} else {
|
||||
*nodeOut++ = n->children[i];
|
||||
*indexOut++ = n->index[i];
|
||||
@@ -1833,7 +1834,7 @@ void eraseBetween(Node48 *&n, int begin, int end, WriteContext *tls) {
|
||||
n->nextFree = 0;
|
||||
for (int i = 0; i < n->numChildren; ++i) {
|
||||
if (inBounds(n->reverseIndex[i])) {
|
||||
destroyTree(n->children[i], &tls->accum.entries_erased);
|
||||
destroyTree(n->children[i], &tls->accum);
|
||||
} else {
|
||||
*nodeOut++ = n->children[i];
|
||||
*indexOut++ = n->reverseIndex[i];
|
||||
@@ -1872,8 +1873,7 @@ void eraseBetween(Node256 *&n, int begin, int end, WriteContext *tls) {
|
||||
BitSet newBitSet;
|
||||
n->bitSet.forEachSet([&](int i) {
|
||||
if (inBounds(i)) {
|
||||
destroyTree(std::exchange(n->children[i], nullptr),
|
||||
&tls->accum.entries_erased);
|
||||
destroyTree(std::exchange(n->children[i], nullptr), &tls->accum);
|
||||
} else {
|
||||
++n->numChildren;
|
||||
newBitSet.set(i);
|
||||
@@ -3393,7 +3393,7 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl {
|
||||
if (oldestExtantVersion < writeVersion - kMaxCorrectVersionWindow)
|
||||
[[unlikely]] {
|
||||
if (writeVersion > newestVersionFullPrecision + kNominalVersionWindow) {
|
||||
destroyTree(root, &tls.accum.entries_erased);
|
||||
destroyTree(root, &tls.accum);
|
||||
init(writeVersion - kNominalVersionWindow);
|
||||
}
|
||||
|
||||
@@ -3562,7 +3562,7 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl {
|
||||
initMetrics();
|
||||
}
|
||||
~Impl() {
|
||||
destroyTree(root, &tls.accum.entries_erased);
|
||||
destroyTree(root, &tls.accum);
|
||||
safe_free(metrics, metricsCount * sizeof(metrics[0]));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user