Optimize version handling in mergeWithChild

This commit is contained in:
2024-08-15 11:49:13 -07:00
parent 7ff00e7846
commit 41840220c3

View File

@@ -1623,7 +1623,7 @@ void mergeWithChild(Node *&self, WriteContext *tls, ConflictSet::Impl *impl,
getSearchPathPrintable(child).c_str());
#endif
InternalVersionT childMaxVersion = maxVersion(child, impl);
InternalVersionT childMaxVersion = self3->childMaxVersion[0];
// Construct new partial key for child
memmove(child->partialKey() + self3->partialKeyLen + 1, child->partialKey(),
@@ -1637,10 +1637,7 @@ void mergeWithChild(Node *&self, WriteContext *tls, ConflictSet::Impl *impl,
// Max versions are stored in the parent, so we need to update it now
// that we have a new parent.
setMaxVersion(child, impl, childMaxVersion);
if (child->parent) {
rezero(child->parent, tls->zero);
}
setMaxVersion(child, impl, std::max(childMaxVersion, tls->zero));
getInTree(self, impl) = child;
tls->release(self3);
@@ -3728,6 +3725,7 @@ InternalVersionT exchangeMaxVersion(Node *n, InternalVersionT newMax) {
}
void setMaxVersion(Node *n, ConflictSet::Impl *impl, InternalVersionT newMax) {
assert(newMax >= InternalVersionT::zero);
int index = n->parentsIndex;
n = n->parent;
if (n == nullptr) {