Add version window constants
This commit is contained in:
@@ -78,13 +78,18 @@ constexpr void removeKey(struct Node *) {}
|
|||||||
|
|
||||||
// ==================== BEGIN IMPLEMENTATION ====================
|
// ==================== BEGIN IMPLEMENTATION ====================
|
||||||
|
|
||||||
|
constexpr int64_t kNominalVersionWindow = 2e9;
|
||||||
|
constexpr int64_t kMaxCorrectVersionWindow =
|
||||||
|
std::numeric_limits<int32_t>::max();
|
||||||
|
static_assert(kNominalVersionWindow <= kMaxCorrectVersionWindow);
|
||||||
|
|
||||||
struct InternalVersionT {
|
struct InternalVersionT {
|
||||||
constexpr InternalVersionT() = default;
|
constexpr InternalVersionT() = default;
|
||||||
constexpr explicit InternalVersionT(int64_t value) : value(value) {}
|
constexpr explicit InternalVersionT(int64_t value) : value(value) {}
|
||||||
constexpr int64_t toInt64() const { return value; } // GCOVR_EXCL_LINE
|
constexpr int64_t toInt64() const { return value; } // GCOVR_EXCL_LINE
|
||||||
constexpr auto operator<=>(const InternalVersionT &rhs) const {
|
constexpr auto operator<=>(const InternalVersionT &rhs) const {
|
||||||
// Maintains ordering after overflow, as long as the full-precision versions
|
// Maintains ordering after overflow, as long as the full-precision versions
|
||||||
// are within ~2e9 of eachother.
|
// are within `kMaxCorrectVersionWindow` of eachother.
|
||||||
return int32_t(value - rhs.value) <=> 0;
|
return int32_t(value - rhs.value) <=> 0;
|
||||||
}
|
}
|
||||||
constexpr bool operator==(const InternalVersionT &) const = default;
|
constexpr bool operator==(const InternalVersionT &) const = default;
|
||||||
@@ -2834,7 +2839,8 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl {
|
|||||||
auto end = std::span<const uint8_t>(r.end.p, r.end.len);
|
auto end = std::span<const uint8_t>(r.end.p, r.end.len);
|
||||||
result[i] =
|
result[i] =
|
||||||
InternalVersionT(reads[i].readVersion) < oldestVersion ||
|
InternalVersionT(reads[i].readVersion) < oldestVersion ||
|
||||||
reads[i].readVersion < newestVersionFullPrecision - 2e9
|
reads[i].readVersion <
|
||||||
|
newestVersionFullPrecision - kNominalVersionWindow
|
||||||
? TooOld
|
? TooOld
|
||||||
: (end.size() > 0
|
: (end.size() > 0
|
||||||
? checkRangeRead(root, begin, end,
|
? checkRangeRead(root, begin, end,
|
||||||
@@ -2950,7 +2956,7 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl {
|
|||||||
InternalVersionT oldestVersion;
|
InternalVersionT oldestVersion;
|
||||||
// TODO this doesn't fully mitigate the 32-bit precision issue, since we still
|
// TODO this doesn't fully mitigate the 32-bit precision issue, since we still
|
||||||
// need to make sure we clean up versions in the tree before they fall out of
|
// need to make sure we clean up versions in the tree before they fall out of
|
||||||
// the 2e9 window.
|
// the `kMaxCorrectVersionWindow` window.
|
||||||
int64_t oldestVersionFullPrecision;
|
int64_t oldestVersionFullPrecision;
|
||||||
int64_t newestVersionFullPrecision;
|
int64_t newestVersionFullPrecision;
|
||||||
int64_t totalBytes = 0;
|
int64_t totalBytes = 0;
|
||||||
|
Reference in New Issue
Block a user