Update DEBUG_VERBOSE for interleaving conflict sets in test

This commit is contained in:
2024-07-23 15:44:29 -07:00
parent 6394995def
commit 42b5d50492
2 changed files with 38 additions and 32 deletions

View File

@@ -581,7 +581,11 @@ namespace {
template <class ConflictSetImpl, bool kEnableAssertions = true> template <class ConflictSetImpl, bool kEnableAssertions = true>
struct TestDriver { struct TestDriver {
Arbitrary *arbitrary; Arbitrary *arbitrary;
explicit TestDriver(Arbitrary &a) : arbitrary(&a) {} explicit TestDriver(Arbitrary &a) : arbitrary(&a) {
#if DEBUG_VERBOSE && !defined(NDEBUG)
fprintf(stderr, "%p Initial version: {%" PRId64 "}\n", this, writeVersion);
#endif
}
int64_t oldestVersion = arbitrary->next(); int64_t oldestVersion = arbitrary->next();
int64_t writeVersion = oldestVersion; int64_t writeVersion = oldestVersion;
@@ -648,23 +652,10 @@ struct TestDriver {
++iter; ++iter;
--rangesRemaining; --rangesRemaining;
} }
#if DEBUG_VERBOSE && !defined(NDEBUG)
if (writes[i].end.len == 0) {
fprintf(stderr, "Write: {%s}\n", printable(writes[i].begin).c_str());
} else {
fprintf(stderr, "Write: [%s, %s)\n",
printable(writes[i].begin).c_str(),
printable(writes[i].end).c_str());
}
#endif
} }
assert(iter == keys.end()); assert(iter == keys.end());
assert(i == numPointWrites + numRangeWrites); assert(i == numPointWrites + numRangeWrites);
#if DEBUG_VERBOSE && !defined(NDEBUG)
fprintf(stderr, "Write @ %" PRId64 "\n", v);
#endif
// Test non-canonical writes // Test non-canonical writes
if (numPointWrites > 0) { if (numPointWrites > 0) {
int overlaps = arbitrary->bounded(numPointWrites); int overlaps = arbitrary->bounded(numPointWrites);
@@ -721,6 +712,20 @@ struct TestDriver {
ready.wait(); ready.wait();
#endif #endif
#if DEBUG_VERBOSE && !defined(NDEBUG)
for (int i = 0; i < numPointWrites + numRangeWrites; ++i) {
if (writes[i].end.len == 0) {
fprintf(stderr, "%p Write: {%s}\n", this,
printable(writes[i].begin).c_str());
} else {
fprintf(stderr, "%p Write: [%s, %s)\n", this,
printable(writes[i].begin).c_str(),
printable(writes[i].end).c_str());
}
}
fprintf(stderr, "%p Write @ %" PRId64 "\n", this, v);
#endif
CALLGRIND_START_INSTRUMENTATION; CALLGRIND_START_INSTRUMENTATION;
cs.addWrites(writes, numPointWrites + numRangeWrites, v); cs.addWrites(writes, numPointWrites + numRangeWrites, v);
CALLGRIND_STOP_INSTRUMENTATION; CALLGRIND_STOP_INSTRUMENTATION;
@@ -729,6 +734,10 @@ struct TestDriver {
refImpl.addWrites(writes, numPointWrites + numRangeWrites, v); refImpl.addWrites(writes, numPointWrites + numRangeWrites, v);
} }
#if DEBUG_VERBOSE && !defined(NDEBUG)
fprintf(stderr, "%p Set oldest version: %" PRId64 "\n", this,
oldestVersion);
#endif
cs.setOldestVersion(oldestVersion); cs.setOldestVersion(oldestVersion);
if constexpr (kEnableAssertions) { if constexpr (kEnableAssertions) {
refImpl.setOldestVersion(oldestVersion); refImpl.setOldestVersion(oldestVersion);
@@ -787,10 +796,10 @@ struct TestDriver {
reads[i].readVersion = v; reads[i].readVersion = v;
#if DEBUG_VERBOSE && !defined(NDEBUG) #if DEBUG_VERBOSE && !defined(NDEBUG)
if (reads[i].end.len == 0) { if (reads[i].end.len == 0) {
fprintf(stderr, "Read: {%s} @ %" PRId64 "\n", fprintf(stderr, "%p Read: {%s} @ %" PRId64 "\n", this,
printable(reads[i].begin).c_str(), reads[i].readVersion); printable(reads[i].begin).c_str(), reads[i].readVersion);
} else { } else {
fprintf(stderr, "Read: [%s, %s) @ %" PRId64 "\n", fprintf(stderr, "%p Read: [%s, %s) @ %" PRId64 "\n", this,
printable(reads[i].begin).c_str(), printable(reads[i].begin).c_str(),
printable(reads[i].end).c_str(), reads[i].readVersion); printable(reads[i].end).c_str(), reads[i].readVersion);
} }
@@ -839,22 +848,23 @@ struct TestDriver {
refImpl.check(reads, results2, numPointReads + numRangeReads); refImpl.check(reads, results2, numPointReads + numRangeReads);
} }
auto compareResults = [reads](ConflictSet::Result *results1, auto compareResults = [reads, this](ConflictSet::Result *results1,
ConflictSet::Result *results2, int count) { ConflictSet::Result *results2,
int count) {
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
if (results1[i] != results2[i]) { if (results1[i] != results2[i]) {
if (reads[i].end.len == 0) { if (reads[i].end.len == 0) {
fprintf(stderr,
"Expected %s, got %s for read of {%s} at version %" PRId64
"\n",
resultToStr(results2[i]), resultToStr(results1[i]),
printable(reads[i].begin).c_str(), reads[i].readVersion);
} else {
fprintf( fprintf(
stderr, stderr,
"Expected %s, got %s for read of [%s, %s) at version %" PRId64 "%p Expected %s, got %s for read of {%s} at version %" PRId64
"\n", "\n",
resultToStr(results2[i]), resultToStr(results1[i]), this, resultToStr(results2[i]), resultToStr(results1[i]),
printable(reads[i].begin).c_str(), reads[i].readVersion);
} else {
fprintf(stderr,
"%p Expected %s, got %s for read of [%s, %s) at version "
"%" PRId64 "\n",
this, resultToStr(results2[i]), resultToStr(results1[i]),
printable(reads[i].begin).c_str(), printable(reads[i].begin).c_str(),
printable(reads[i].end).c_str(), reads[i].readVersion); printable(reads[i].end).c_str(), reads[i].readVersion);
} }

View File

@@ -778,10 +778,6 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl {
for (int s = stripes - 1; s >= 0; s--) { for (int s = stripes - 1; s >= 0; s--) {
for (int i = 0; i * 2 < ss; ++i) { for (int i = 0; i * 2 < ss; ++i) {
const auto &w = combinedWriteConflictRanges[s * stripeSize / 2 + i]; const auto &w = combinedWriteConflictRanges[s * stripeSize / 2 + i];
#if DEBUG_VERBOSE
printf("Write begin: %s\n", printable(w.begin).c_str());
fflush(stdout);
#endif
values[i * 2] = w.first; values[i * 2] = w.first;
values[i * 2 + 1] = w.second; values[i * 2 + 1] = w.second;
keyUpdates += 3; keyUpdates += 3;