Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c11b4714b5 | |||
| bc13094406 |
+22
-10
@@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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])))
|
||||||
|
|||||||
Reference in New Issue
Block a user