Improve codegen for tracking check metrics
This commit is contained in:
@@ -2978,7 +2978,7 @@ struct CheckContext {
|
|||||||
const ConflictSet::ReadRange *queries;
|
const ConflictSet::ReadRange *queries;
|
||||||
ConflictSet::Result *results;
|
ConflictSet::Result *results;
|
||||||
int64_t started;
|
int64_t started;
|
||||||
ReadContext *tls;
|
ReadContext tls;
|
||||||
#if !__has_attribute(musttail)
|
#if !__has_attribute(musttail)
|
||||||
CheckJob *job;
|
CheckJob *job;
|
||||||
bool done;
|
bool done;
|
||||||
@@ -3034,7 +3034,7 @@ static Continuation iterTable[] = {iter<Node0>, iter<Node3>, iter<Node16>,
|
|||||||
iter<Node48>, iter<Node256>};
|
iter<Node48>, iter<Node256>};
|
||||||
|
|
||||||
void begin(CheckJob *job, CheckContext *context) {
|
void begin(CheckJob *job, CheckContext *context) {
|
||||||
++context->tls->point_read_accum;
|
++context->tls.point_read_accum;
|
||||||
#if DEBUG_VERBOSE && !defined(NDEBUG)
|
#if DEBUG_VERBOSE && !defined(NDEBUG)
|
||||||
fprintf(stderr, "Check point read: %s\n", printable(key).c_str());
|
fprintf(stderr, "Check point read: %s\n", printable(key).c_str());
|
||||||
#endif
|
#endif
|
||||||
@@ -3104,11 +3104,11 @@ template <class NodeT> void iter(CheckJob *job, CheckContext *context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
++context->tls->point_read_iterations_accum;
|
++context->tls.point_read_iterations_accum;
|
||||||
|
|
||||||
if (job->maxV <= job->readVersion) {
|
if (job->maxV <= job->readVersion) {
|
||||||
job->setResult(true);
|
job->setResult(true);
|
||||||
++context->tls->point_read_short_circuit_accum;
|
++context->tls.point_read_short_circuit_accum;
|
||||||
MUSTTAIL return complete(job, context);
|
MUSTTAIL return complete(job, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3162,7 +3162,7 @@ static Continuation iterTable[] = {iter<Node0>, iter<Node3>, iter<Node16>,
|
|||||||
iter<Node48>, iter<Node256>};
|
iter<Node48>, iter<Node256>};
|
||||||
|
|
||||||
void begin(CheckJob *job, CheckContext *context) {
|
void begin(CheckJob *job, CheckContext *context) {
|
||||||
++context->tls->prefix_read_accum;
|
++context->tls.prefix_read_accum;
|
||||||
#if DEBUG_VERBOSE && !defined(NDEBUG)
|
#if DEBUG_VERBOSE && !defined(NDEBUG)
|
||||||
fprintf(stderr, "Check prefix read: %s\n", printable(key).c_str());
|
fprintf(stderr, "Check prefix read: %s\n", printable(key).c_str());
|
||||||
#endif
|
#endif
|
||||||
@@ -3233,11 +3233,11 @@ template <class NodeT> void iter(CheckJob *job, CheckContext *context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
++context->tls->prefix_read_iterations_accum;
|
++context->tls.prefix_read_iterations_accum;
|
||||||
|
|
||||||
if (job->maxV <= job->readVersion) {
|
if (job->maxV <= job->readVersion) {
|
||||||
job->setResult(true);
|
job->setResult(true);
|
||||||
++context->tls->prefix_read_short_circuit_accum;
|
++context->tls.prefix_read_short_circuit_accum;
|
||||||
MUSTTAIL return complete(job, context);
|
MUSTTAIL return complete(job, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3329,7 +3329,7 @@ PRESERVE_NONE void begin(CheckJob *job, CheckContext *context) {
|
|||||||
MUSTTAIL return job->continuation(job, context);
|
MUSTTAIL return job->continuation(job, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
++context->tls->range_read_accum;
|
++context->tls.range_read_accum;
|
||||||
job->remaining = job->begin.subspan(0, job->lcp);
|
job->remaining = job->begin.subspan(0, job->lcp);
|
||||||
|
|
||||||
if (job->remaining.size() == 0) {
|
if (job->remaining.size() == 0) {
|
||||||
@@ -3371,11 +3371,11 @@ void common_prefix_iter(CheckJob *job, CheckContext *context) {
|
|||||||
job->remaining.size() -
|
job->remaining.size() -
|
||||||
(1 + child->partialKeyLen));
|
(1 + child->partialKeyLen));
|
||||||
|
|
||||||
++context->tls->range_read_iterations_accum;
|
++context->tls.range_read_iterations_accum;
|
||||||
|
|
||||||
if (job->maxV <= job->readVersion) {
|
if (job->maxV <= job->readVersion) {
|
||||||
job->setResult(true);
|
job->setResult(true);
|
||||||
++context->tls->range_read_short_circuit_accum;
|
++context->tls.range_read_short_circuit_accum;
|
||||||
MUSTTAIL return complete(job, context);
|
MUSTTAIL return complete(job, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3427,7 +3427,7 @@ PRESERVE_NONE void done_common_prefix_iter(CheckJob *job,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!checkMaxBetweenExclusive(n, -1, job->remaining[0], job->readVersion,
|
if (!checkMaxBetweenExclusive(n, -1, job->remaining[0], job->readVersion,
|
||||||
context->tls)) {
|
&context->tls)) {
|
||||||
job->setResult(false);
|
job->setResult(false);
|
||||||
MUSTTAIL return complete(job, context);
|
MUSTTAIL return complete(job, context);
|
||||||
}
|
}
|
||||||
@@ -3466,7 +3466,7 @@ PRESERVE_NONE void done_common_prefix_iter(CheckJob *job,
|
|||||||
|
|
||||||
if (!checkRangeStartsWith(n, job->begin.subspan(0, job->lcp),
|
if (!checkRangeStartsWith(n, job->begin.subspan(0, job->lcp),
|
||||||
job->begin[job->lcp], job->end[job->lcp],
|
job->begin[job->lcp], job->end[job->lcp],
|
||||||
job->readVersion, context->tls)) {
|
job->readVersion, &context->tls)) {
|
||||||
job->setResult(false);
|
job->setResult(false);
|
||||||
MUSTTAIL return complete(job, context);
|
MUSTTAIL return complete(job, context);
|
||||||
}
|
}
|
||||||
@@ -3561,7 +3561,7 @@ PRESERVE_NONE void left_side_iter(CheckJob *job, CheckContext *context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
++context->tls->range_read_iterations_accum;
|
++context->tls.range_read_iterations_accum;
|
||||||
|
|
||||||
if (job->maxV <= job->readVersion) {
|
if (job->maxV <= job->readVersion) {
|
||||||
job->continuation = done_left_side_iter;
|
job->continuation = done_left_side_iter;
|
||||||
@@ -3575,7 +3575,7 @@ PRESERVE_NONE void left_side_iter(CheckJob *job, CheckContext *context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!checkMaxBetweenExclusive(n, job->remaining[0], 256, job->readVersion,
|
if (!checkMaxBetweenExclusive(n, job->remaining[0], 256, job->readVersion,
|
||||||
context->tls)) {
|
&context->tls)) {
|
||||||
job->setResult(false);
|
job->setResult(false);
|
||||||
MUSTTAIL return complete(job, context);
|
MUSTTAIL return complete(job, context);
|
||||||
}
|
}
|
||||||
@@ -3699,7 +3699,7 @@ PRESERVE_NONE void right_side_iter(CheckJob *job, CheckContext *context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
++context->tls->range_read_iterations_accum;
|
++context->tls.range_read_iterations_accum;
|
||||||
|
|
||||||
if (job->remaining.size() == 0) {
|
if (job->remaining.size() == 0) {
|
||||||
job->continuation = down_left_spine;
|
job->continuation = down_left_spine;
|
||||||
@@ -3713,7 +3713,7 @@ PRESERVE_NONE void right_side_iter(CheckJob *job, CheckContext *context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!checkMaxBetweenExclusive(n, -1, job->remaining[0], job->readVersion,
|
if (!checkMaxBetweenExclusive(n, -1, job->remaining[0], job->readVersion,
|
||||||
context->tls)) {
|
&context->tls)) {
|
||||||
job->setResult(false);
|
job->setResult(false);
|
||||||
MUSTTAIL return complete(job, context);
|
MUSTTAIL return complete(job, context);
|
||||||
}
|
}
|
||||||
@@ -3779,18 +3779,16 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReadContext tls;
|
|
||||||
tls.impl = this;
|
|
||||||
int64_t check_byte_accum = 0;
|
int64_t check_byte_accum = 0;
|
||||||
constexpr int kConcurrent = 16;
|
constexpr int kConcurrent = 16;
|
||||||
CheckJob inProgress[kConcurrent];
|
CheckJob inProgress[kConcurrent];
|
||||||
CheckContext context;
|
CheckContext context;
|
||||||
|
context.tls.impl = this;
|
||||||
context.count = count;
|
context.count = count;
|
||||||
context.oldestVersionFullPrecision = oldestVersionFullPrecision;
|
context.oldestVersionFullPrecision = oldestVersionFullPrecision;
|
||||||
context.root = root;
|
context.root = root;
|
||||||
context.queries = reads;
|
context.queries = reads;
|
||||||
context.results = result;
|
context.results = result;
|
||||||
context.tls = &tls;
|
|
||||||
int64_t started = std::min(kConcurrent, count);
|
int64_t started = std::min(kConcurrent, count);
|
||||||
context.started = started;
|
context.started = started;
|
||||||
for (int i = 0; i < started; i++) {
|
for (int i = 0; i < started; i++) {
|
||||||
@@ -3823,24 +3821,27 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl {
|
|||||||
assert(reads[i].readVersion <= newestVersionFullPrecision);
|
assert(reads[i].readVersion <= newestVersionFullPrecision);
|
||||||
const auto &r = reads[i];
|
const auto &r = reads[i];
|
||||||
check_byte_accum += r.begin.len + r.end.len;
|
check_byte_accum += r.begin.len + r.end.len;
|
||||||
tls.commits_accum += result[i] == Commit;
|
context.tls.commits_accum += result[i] == Commit;
|
||||||
tls.conflicts_accum += result[i] == Conflict;
|
context.tls.conflicts_accum += result[i] == Conflict;
|
||||||
tls.too_olds_accum += result[i] == TooOld;
|
context.tls.too_olds_accum += result[i] == TooOld;
|
||||||
}
|
}
|
||||||
|
|
||||||
point_read_total.add(tls.point_read_accum);
|
point_read_total.add(context.tls.point_read_accum);
|
||||||
prefix_read_total.add(tls.prefix_read_accum);
|
prefix_read_total.add(context.tls.prefix_read_accum);
|
||||||
range_read_total.add(tls.range_read_accum);
|
range_read_total.add(context.tls.range_read_accum);
|
||||||
range_read_node_scan_total.add(tls.range_read_node_scan_accum);
|
range_read_node_scan_total.add(context.tls.range_read_node_scan_accum);
|
||||||
point_read_short_circuit_total.add(tls.point_read_short_circuit_accum);
|
point_read_short_circuit_total.add(
|
||||||
prefix_read_short_circuit_total.add(tls.prefix_read_short_circuit_accum);
|
context.tls.point_read_short_circuit_accum);
|
||||||
range_read_short_circuit_total.add(tls.range_read_short_circuit_accum);
|
prefix_read_short_circuit_total.add(
|
||||||
point_read_iterations_total.add(tls.point_read_iterations_accum);
|
context.tls.prefix_read_short_circuit_accum);
|
||||||
prefix_read_iterations_total.add(tls.prefix_read_iterations_accum);
|
range_read_short_circuit_total.add(
|
||||||
range_read_iterations_total.add(tls.range_read_iterations_accum);
|
context.tls.range_read_short_circuit_accum);
|
||||||
commits_total.add(tls.commits_accum);
|
point_read_iterations_total.add(context.tls.point_read_iterations_accum);
|
||||||
conflicts_total.add(tls.conflicts_accum);
|
prefix_read_iterations_total.add(context.tls.prefix_read_iterations_accum);
|
||||||
too_olds_total.add(tls.too_olds_accum);
|
range_read_iterations_total.add(context.tls.range_read_iterations_accum);
|
||||||
|
commits_total.add(context.tls.commits_accum);
|
||||||
|
conflicts_total.add(context.tls.conflicts_accum);
|
||||||
|
too_olds_total.add(context.tls.too_olds_accum);
|
||||||
check_bytes_total.add(check_byte_accum);
|
check_bytes_total.add(check_byte_accum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user