Compare commits
4 Commits
147f5af16b
...
73f93edf49
| Author | SHA1 | Date | |
|---|---|---|---|
| 73f93edf49 | |||
| 8bac1f66fc | |||
| 352c07cbc9 | |||
| 2e7e357355 |
104
ConflictSet.cpp
104
ConflictSet.cpp
@@ -2937,8 +2937,6 @@ struct CheckJob {
|
||||
std::span<const uint8_t> remaining; // range read only
|
||||
Node *child; // range read only
|
||||
int lcp; // range read only
|
||||
int prefixLen; // range read only
|
||||
int searchPathLen; // range read only
|
||||
Node *commonPrefixNode; // range read only
|
||||
InternalVersionT readVersion;
|
||||
ConflictSet::Result *result;
|
||||
@@ -3263,16 +3261,21 @@ static Continuation commonPrefixIterTable[] = {
|
||||
common_prefix_iter<Node16>, common_prefix_iter<Node48>,
|
||||
common_prefix_iter<Node256>};
|
||||
|
||||
template <class NodeT>
|
||||
template <class NodeT, bool kFirst>
|
||||
PRESERVE_NONE void left_side_iter(CheckJob *, CheckContext *);
|
||||
|
||||
PRESERVE_NONE void left_side_down_left_spine(CheckJob *, CheckContext *);
|
||||
|
||||
PRESERVE_NONE void done_left_side_iter(CheckJob *, CheckContext *);
|
||||
|
||||
static Continuation leftSideIterTable[] = {
|
||||
left_side_iter<Node0>, left_side_iter<Node3>, left_side_iter<Node16>,
|
||||
left_side_iter<Node48>, left_side_iter<Node256>};
|
||||
static Continuation leftSideIterTable[2][5] = {
|
||||
{left_side_iter<Node0, false>, left_side_iter<Node3, false>,
|
||||
left_side_iter<Node16, false>, left_side_iter<Node48, false>,
|
||||
left_side_iter<Node256, false>},
|
||||
{left_side_iter<Node0, true>, left_side_iter<Node3, true>,
|
||||
left_side_iter<Node16, true>, left_side_iter<Node48, true>,
|
||||
left_side_iter<Node256, true>},
|
||||
};
|
||||
|
||||
PRESERVE_NONE void begin(CheckJob *job, CheckContext *context) {
|
||||
job->lcp = longestCommonPrefix(job->begin.data(), job->end.data(),
|
||||
@@ -3365,65 +3368,32 @@ PRESERVE_NONE void done_common_prefix_iter(CheckJob *job,
|
||||
job->commonPrefixNode = job->n;
|
||||
|
||||
if (job->lcp == int(job->begin.size())) {
|
||||
*job->result = checkRangeRightSide(job->n, job->end, job->lcp,
|
||||
job->readVersion, context->tls)
|
||||
? ConflictSet::Commit
|
||||
: ConflictSet::Conflict;
|
||||
job->setResult(checkRangeRightSide(job->n, job->end, job->lcp,
|
||||
job->readVersion, context->tls));
|
||||
MUSTTAIL return complete(job, context);
|
||||
}
|
||||
|
||||
// This makes it safe to check maxVersion within checkRangeLeftSide. If this
|
||||
// were false, then we would have returned above since lcp == begin.size().
|
||||
assert(!(job->n->parent == nullptr && job->begin.size() == 0));
|
||||
// If this were not true we would have returned above
|
||||
assert(job->begin.size() > 0);
|
||||
|
||||
if (!checkRangeStartsWith(job->n, job->begin.subspan(0, job->lcp),
|
||||
job->begin[job->lcp], job->end[job->lcp],
|
||||
job->readVersion, context->tls)) {
|
||||
*job->result = ConflictSet::Conflict;
|
||||
job->setResult(false);
|
||||
MUSTTAIL return complete(job, context);
|
||||
}
|
||||
|
||||
job->remaining = job->begin;
|
||||
job->searchPathLen = 0;
|
||||
job->prefixLen = job->lcp + 1;
|
||||
|
||||
if (job->remaining.size() == 0) {
|
||||
assert(job->searchPathLen >= job->prefixLen);
|
||||
if (maxVersion(job->n) > job->readVersion) {
|
||||
job->setResult(false);
|
||||
MUSTTAIL return complete(job, context);
|
||||
} else {
|
||||
job->continuation = done_left_side_iter;
|
||||
MUSTTAIL return job->continuation(job, context);
|
||||
}
|
||||
}
|
||||
|
||||
if (job->searchPathLen >= job->prefixLen) {
|
||||
if (!checkMaxBetweenExclusive(job->n, job->remaining[0], 256,
|
||||
job->readVersion, context->tls)) {
|
||||
job->setResult(false);
|
||||
MUSTTAIL return complete(job, context);
|
||||
}
|
||||
}
|
||||
|
||||
auto c = getChild(job->n, job->remaining[0]);
|
||||
Node *child = c;
|
||||
if (child == nullptr) {
|
||||
auto c = getChildGeq(job->n, job->remaining[0]);
|
||||
if (c != nullptr) {
|
||||
if (job->searchPathLen < job->prefixLen) {
|
||||
job->n = c;
|
||||
job->continuation = left_side_down_left_spine;
|
||||
__builtin_prefetch(job->n);
|
||||
MUSTTAIL return keepGoing(job, context);
|
||||
}
|
||||
job->n = c;
|
||||
if (maxVersion(job->n) > job->readVersion) {
|
||||
job->setResult(false);
|
||||
MUSTTAIL return complete(job, context);
|
||||
}
|
||||
job->continuation = done_left_side_iter;
|
||||
MUSTTAIL return job->continuation(job, context);
|
||||
job->continuation = left_side_down_left_spine;
|
||||
__builtin_prefetch(job->n);
|
||||
MUSTTAIL return keepGoing(job, context);
|
||||
} else {
|
||||
job->n = nextSibling(job->n);
|
||||
if (job->n == nullptr) {
|
||||
@@ -3437,32 +3407,32 @@ PRESERVE_NONE void done_common_prefix_iter(CheckJob *job,
|
||||
}
|
||||
|
||||
job->n = child;
|
||||
job->continuation = leftSideIterTable[c.getType()];
|
||||
job->continuation = leftSideIterTable[true][c.getType()];
|
||||
__builtin_prefetch(job->n);
|
||||
MUSTTAIL return keepGoing(job, context);
|
||||
}
|
||||
|
||||
// Return true if the max version among all keys that start with key[:prefixLen]
|
||||
// that are >= key is <= readVersion
|
||||
template <class NodeT>
|
||||
template <class NodeT, bool kFirst>
|
||||
PRESERVE_NONE void left_side_iter(CheckJob *job, CheckContext *context) {
|
||||
assert(NodeT::kType == job->n->getType());
|
||||
NodeT *n = static_cast<NodeT *>(job->n);
|
||||
|
||||
job->remaining = job->remaining.subspan(1, job->remaining.size() - 1);
|
||||
++job->searchPathLen;
|
||||
|
||||
if (n->partialKeyLen > 0) {
|
||||
int commonLen = std::min<int>(n->partialKeyLen, job->remaining.size());
|
||||
int i =
|
||||
longestCommonPrefix(n->partialKey(), job->remaining.data(), commonLen);
|
||||
job->searchPathLen += i;
|
||||
if (i < commonLen) {
|
||||
auto c = n->partialKey()[i] <=> job->remaining[i];
|
||||
if (c > 0) {
|
||||
if (job->searchPathLen < job->prefixLen) {
|
||||
job->continuation = left_side_down_left_spine;
|
||||
MUSTTAIL return job->continuation(job, context);
|
||||
if constexpr (kFirst) {
|
||||
if (i < job->lcp) {
|
||||
job->continuation = left_side_down_left_spine;
|
||||
MUSTTAIL return job->continuation(job, context);
|
||||
}
|
||||
}
|
||||
if (n->entryPresent && n->entry.rangeVersion > job->readVersion) {
|
||||
job->setResult(false);
|
||||
@@ -3489,7 +3459,6 @@ PRESERVE_NONE void left_side_iter(CheckJob *job, CheckContext *context) {
|
||||
job->remaining =
|
||||
job->remaining.subspan(commonLen, job->remaining.size() - commonLen);
|
||||
} else if (n->partialKeyLen > int(job->remaining.size())) {
|
||||
assert(job->searchPathLen >= job->prefixLen);
|
||||
if (n->entryPresent && n->entry.rangeVersion > job->readVersion) {
|
||||
job->setResult(false);
|
||||
MUSTTAIL return complete(job, context);
|
||||
@@ -3506,9 +3475,8 @@ PRESERVE_NONE void left_side_iter(CheckJob *job, CheckContext *context) {
|
||||
++context->tls->range_read_iterations_accum;
|
||||
|
||||
if (job->remaining.size() == 0) {
|
||||
assert(job->searchPathLen >= job->prefixLen);
|
||||
if (maxVersion(n) > job->readVersion) {
|
||||
*job->result = ConflictSet::Conflict;
|
||||
job->setResult(false);
|
||||
MUSTTAIL return complete(job, context);
|
||||
} else {
|
||||
job->continuation = done_left_side_iter;
|
||||
@@ -3516,12 +3484,10 @@ PRESERVE_NONE void left_side_iter(CheckJob *job, CheckContext *context) {
|
||||
}
|
||||
}
|
||||
|
||||
if (job->searchPathLen >= job->prefixLen) {
|
||||
if (!checkMaxBetweenExclusive(n, job->remaining[0], 256, job->readVersion,
|
||||
context->tls)) {
|
||||
*job->result = ConflictSet::Conflict;
|
||||
MUSTTAIL return complete(job, context);
|
||||
}
|
||||
if (!checkMaxBetweenExclusive(n, job->remaining[0], 256, job->readVersion,
|
||||
context->tls)) {
|
||||
job->setResult(false);
|
||||
MUSTTAIL return complete(job, context);
|
||||
}
|
||||
|
||||
auto c = getChild(n, job->remaining[0]);
|
||||
@@ -3529,17 +3495,7 @@ PRESERVE_NONE void left_side_iter(CheckJob *job, CheckContext *context) {
|
||||
if (child == nullptr) {
|
||||
auto c = getChildGeq(n, job->remaining[0]);
|
||||
if (c != nullptr) {
|
||||
if (job->searchPathLen < job->prefixLen) {
|
||||
job->n = c;
|
||||
job->continuation = left_side_down_left_spine;
|
||||
__builtin_prefetch(job->n);
|
||||
MUSTTAIL return keepGoing(job, context);
|
||||
}
|
||||
job->n = c;
|
||||
if (maxVersion(job->n) > job->readVersion) {
|
||||
*job->result = ConflictSet::Conflict;
|
||||
MUSTTAIL return complete(job, context);
|
||||
}
|
||||
job->continuation = done_left_side_iter;
|
||||
MUSTTAIL return job->continuation(job, context);
|
||||
} else {
|
||||
@@ -3555,7 +3511,7 @@ PRESERVE_NONE void left_side_iter(CheckJob *job, CheckContext *context) {
|
||||
}
|
||||
|
||||
job->n = child;
|
||||
job->continuation = leftSideIterTable[c.getType()];
|
||||
job->continuation = leftSideIterTable[false][c.getType()];
|
||||
__builtin_prefetch(job->n);
|
||||
MUSTTAIL return keepGoing(job, context);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user