From 42b5d50492ae1541aadf7a6608e2dfef2a79421f Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Tue, 23 Jul 2024 15:44:29 -0700 Subject: [PATCH] Update DEBUG_VERBOSE for interleaving conflict sets in test --- Internal.h | 66 ++++++++++++++++++++++++++++++---------------------- SkipList.cpp | 4 ---- 2 files changed, 38 insertions(+), 32 deletions(-) diff --git a/Internal.h b/Internal.h index e86f8bb..8b79a1e 100644 --- a/Internal.h +++ b/Internal.h @@ -581,7 +581,11 @@ namespace { template struct TestDriver { 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 writeVersion = oldestVersion; @@ -648,23 +652,10 @@ struct TestDriver { ++iter; --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(i == numPointWrites + numRangeWrites); -#if DEBUG_VERBOSE && !defined(NDEBUG) - fprintf(stderr, "Write @ %" PRId64 "\n", v); -#endif - // Test non-canonical writes if (numPointWrites > 0) { int overlaps = arbitrary->bounded(numPointWrites); @@ -721,6 +712,20 @@ struct TestDriver { ready.wait(); #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; cs.addWrites(writes, numPointWrites + numRangeWrites, v); CALLGRIND_STOP_INSTRUMENTATION; @@ -729,6 +734,10 @@ struct TestDriver { 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); if constexpr (kEnableAssertions) { refImpl.setOldestVersion(oldestVersion); @@ -787,10 +796,10 @@ struct TestDriver { reads[i].readVersion = v; #if DEBUG_VERBOSE && !defined(NDEBUG) 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); } 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].end).c_str(), reads[i].readVersion); } @@ -839,24 +848,25 @@ struct TestDriver { refImpl.check(reads, results2, numPointReads + numRangeReads); } - auto compareResults = [reads](ConflictSet::Result *results1, - ConflictSet::Result *results2, int count) { + auto compareResults = [reads, this](ConflictSet::Result *results1, + ConflictSet::Result *results2, + int count) { for (int i = 0; i < count; ++i) { if (results1[i] != results2[i]) { 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( 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", - resultToStr(results2[i]), resultToStr(results1[i]), - printable(reads[i].begin).c_str(), - printable(reads[i].end).c_str(), reads[i].readVersion); + 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].end).c_str(), reads[i].readVersion); } return false; } diff --git a/SkipList.cpp b/SkipList.cpp index 8559926..2e5a477 100644 --- a/SkipList.cpp +++ b/SkipList.cpp @@ -778,10 +778,6 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl { for (int s = stripes - 1; s >= 0; s--) { for (int i = 0; i * 2 < ss; ++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 + 1] = w.second; keyUpdates += 3;