2 Commits

Author SHA1 Message Date
c11b4714b5 Check more preconditions in Debug mode
All checks were successful
Tests / Clang total: 2843, passed: 2843
Clang |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |0|0|0|0|:clap:
Tests / 64 bit versions total: 2843, passed: 2843
Tests / Debug total: 2841, passed: 2841
Tests / SIMD fallback total: 2843, passed: 2843
Tests / Release [gcc] total: 2843, passed: 2843
GNU C Compiler (gcc) |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |0|0|0|0|:clap:
Tests / Release [gcc,aarch64] total: 2119, passed: 2119
Tests / Coverage total: 2136, passed: 2136
Code Coverage #### Project Overview No changes detected, that affect the code coverage. * Line Coverage: 98.92% (1834/1854) * Branch Coverage: 66.85% (1496/2238) * Complexity Density: 0.00 * Lines of Code: 1854 #### Quality Gates Summary Output truncated.
weaselab/conflict-set/pipeline/head This commit looks good
2024-08-26 12:43:07 -07:00
bc13094406 Don't violate precondition in test_conflict_set.py 2024-08-26 11:13:16 -07:00
2 changed files with 23 additions and 10 deletions

View File

@@ -2912,9 +2912,8 @@ checkMaxBetweenExclusiveImpl<true>(Node *n, int begin, int end,
// of the result will have `maxVersion` set to `writeVersion` as a // of the result will have `maxVersion` set to `writeVersion` as a
// postcondition. Nodes along the search path may be invalidated. Callers must // postcondition. Nodes along the search path may be invalidated. Callers must
// ensure that the max version of the self argument is updated. // ensure that the max version of the self argument is updated.
[[nodiscard]] [[nodiscard]] Node **insert(Node **self, std::span<const uint8_t> key,
Node **insert(Node **self, std::span<const uint8_t> key, InternalVersionT writeVersion, WriteContext *tls) {
InternalVersionT writeVersion, WriteContext *tls) {
for (; key.size() != 0; ++tls->accum.insert_iterations) { for (; key.size() != 0; ++tls->accum.insert_iterations) {
self = &getOrCreateChild(*self, key, writeVersion, tls); self = &getOrCreateChild(*self, key, writeVersion, tls);
@@ -3149,6 +3148,7 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl {
tls.impl = this; tls.impl = this;
int64_t check_byte_accum = 0; int64_t check_byte_accum = 0;
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
assert(reads[i].readVersion >= 0);
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;
@@ -3206,7 +3206,10 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl {
newestVersionFullPrecision = writeVersion; newestVersionFullPrecision = writeVersion;
newest_version.set(newestVersionFullPrecision); newest_version.set(newestVersionFullPrecision);
setOldestVersion(newestVersionFullPrecision - kNominalVersionWindow); if (newestVersionFullPrecision - kNominalVersionWindow >
oldestVersionFullPrecision) {
setOldestVersion(newestVersionFullPrecision - kNominalVersionWindow);
}
while (oldestExtantVersion < while (oldestExtantVersion <
newestVersionFullPrecision - kMaxCorrectVersionWindow) { newestVersionFullPrecision - kMaxCorrectVersionWindow) {
gcScanStep(1000); gcScanStep(1000);
@@ -3214,7 +3217,10 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl {
} else { } else {
newestVersionFullPrecision = writeVersion; newestVersionFullPrecision = writeVersion;
newest_version.set(newestVersionFullPrecision); newest_version.set(newestVersionFullPrecision);
setOldestVersion(newestVersionFullPrecision - kNominalVersionWindow); if (newestVersionFullPrecision - kNominalVersionWindow >
oldestVersionFullPrecision) {
setOldestVersion(newestVersionFullPrecision - kNominalVersionWindow);
}
} }
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
@@ -3299,13 +3305,18 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl {
return fuel; return fuel;
} }
void setOldestVersion(int64_t o) { void setOldestVersion(int64_t newOldestVersion) {
assert(o <= newestVersionFullPrecision); assert(newOldestVersion >= 0);
if (o <= oldestVersionFullPrecision) { assert(newOldestVersion <= newestVersionFullPrecision);
// If addWrites advances oldestVersion to keep within valid window, a
// subsequent setOldestVersion can be legitimately called with a version
// older than `oldestVersionFullPrecision`. < instead of <= so that we can
// do garbage collection work without advancing the oldest version.
if (newOldestVersion < oldestVersionFullPrecision) {
return; return;
} }
InternalVersionT oldestVersion{o}; InternalVersionT oldestVersion{newOldestVersion};
this->oldestVersionFullPrecision = o; this->oldestVersionFullPrecision = newOldestVersion;
this->oldestVersion = oldestVersion; this->oldestVersion = oldestVersion;
#if !USE_64_BIT #if !USE_64_BIT
InternalVersionT::zero = tls.zero = oldestVersion; InternalVersionT::zero = tls.zero = oldestVersion;
@@ -3366,6 +3377,7 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl {
} }
explicit Impl(int64_t oldestVersion) { explicit Impl(int64_t oldestVersion) {
assert(oldestVersion >= 0);
init(oldestVersion); init(oldestVersion);
initMetrics(); initMetrics();
} }

View File

@@ -96,6 +96,7 @@ def test_inner_full_words():
def test_internal_version_zero(): def test_internal_version_zero():
with DebugConflictSet() as cs: with DebugConflictSet() as cs:
cs.addWrites(0xFFFFFFF0)
cs.setOldestVersion(0xFFFFFFF0) cs.setOldestVersion(0xFFFFFFF0)
for i in range(24): for i in range(24):
cs.addWrites(0xFFFFFFF1, write(bytes([i]))) cs.addWrites(0xFFFFFFF1, write(bytes([i])))