Compute the TooOld window in integer arithmetic (#99) #102

Open
weaselbot wants to merge 1 commits from weaselbot/conflict-set:weaselbot/issue-99 into main
pull from: weaselbot/conflict-set:weaselbot/issue-99
Member

Closes #99.

SkipList.cpp decided TooOld with reads[i].readVersion < newestVersion - 2e9, where 2e9 is a double literal. The subtraction and comparison were therefore done in double, and since a double has a 53 bit mantissa the boundary newestVersion - 2000000000 was off by up to ~512 versions for newestVersion >= 2^53. skip_list returned Commit for reads one version below the window (the case the window exists to prevent) and TooOld for reads exactly at it. ReferenceImpl::check in Internal.h had the same expression, so the TestDriver/corpus oracle agreed with the bug.

Changes:

  • Move the window to a single integer constant, kNominalVersionWindow = 2000000000, in Internal.h, next to a comment explaining why it must not be a double, and use it in both SkipList.cpp and ReferenceImpl::check.
  • Drop the duplicate definition from ConflictSet.cpp (it was already constexpr int64_t, so the radix tree was correct; it now shares the same constant).
  • Add test_too_old_window_precision to test_conflict_set.py, which bisimulates skip_list against the radix tree at and one below the window boundary for newestVersion in {2^53, 2^53+1, 2^53+7, INT64_MAX}. It fails without the fix (the skip list disagrees with the radix tree) and passes with it.

Verification:

  • The issue's repro now prints TooOld with exit 0 for both shipped implementations.
  • ctest -R 'script_test|api_test|show_memory|interleaving': 39/39 pass (includes the new test, also under valgrind).
  • All 2874 conflict_set_blackbox_* and all 2845 conflict_set_fuzz_* corpus tests (radix tree vs. the fixed ReferenceImpl oracle) pass.
  • driver_skip_list (skip_list vs. ReferenceImpl) passes on a sample of 60 corpus tests.
  • clang-format, black, and the other pre-commit hooks pass.
Closes #99. `SkipList.cpp` decided `TooOld` with `reads[i].readVersion < newestVersion - 2e9`, where `2e9` is a `double` literal. The subtraction and comparison were therefore done in `double`, and since a `double` has a 53 bit mantissa the boundary `newestVersion - 2000000000` was off by up to ~512 versions for `newestVersion >= 2^53`. skip_list returned `Commit` for reads one version below the window (the case the window exists to prevent) and `TooOld` for reads exactly at it. `ReferenceImpl::check` in `Internal.h` had the same expression, so the `TestDriver`/corpus oracle agreed with the bug. Changes: - Move the window to a single integer constant, `kNominalVersionWindow = 2000000000`, in `Internal.h`, next to a comment explaining why it must not be a `double`, and use it in both `SkipList.cpp` and `ReferenceImpl::check`. - Drop the duplicate definition from `ConflictSet.cpp` (it was already `constexpr int64_t`, so the radix tree was correct; it now shares the same constant). - Add `test_too_old_window_precision` to `test_conflict_set.py`, which bisimulates skip_list against the radix tree at and one below the window boundary for `newestVersion` in `{2^53, 2^53+1, 2^53+7, INT64_MAX}`. It fails without the fix (the skip list disagrees with the radix tree) and passes with it. Verification: - The issue's repro now prints `TooOld` with exit 0 for both shipped implementations. - `ctest -R 'script_test|api_test|show_memory|interleaving'`: 39/39 pass (includes the new test, also under valgrind). - All 2874 `conflict_set_blackbox_*` and all 2845 `conflict_set_fuzz_*` corpus tests (radix tree vs. the fixed `ReferenceImpl` oracle) pass. - `driver_skip_list` (skip_list vs. `ReferenceImpl`) passes on a sample of 60 corpus tests. - `clang-format`, `black`, and the other pre-commit hooks pass.
weaselbot added 1 commit 2026-11-10 20:20:53 +00:00
Compute the TooOld window in integer arithmetic
CI / test (arm64, -DCMAKE_BUILD_TYPE=Debug -DMSAN_TOOLCHAIN_PATH=/opt/msan, 22, https://minio.weaselab.dev/public/aarch64/msan-toolchain-22.1.8.tar.zst, debug-arm64, ubuntu-latest-arm64) (pull_request) Successful in 3m54s
CI / release (arm64, , ubuntu-latest-arm64) (pull_request) Successful in 4m26s
CI / pre-commit (pull_request) Successful in 2m14s
CI / test (amd64, -DCMAKE_BUILD_TYPE=Debug -DMSAN_TOOLCHAIN_PATH=/opt/msan, 21, https://minio.weaselab.dev/public/x86_64/msan-toolchain-21.1.8.tar.zst, debug, ubuntu-latest-amd64) (pull_request) Successful in 4m1s
CI / test (amd64, -DCMAKE_CXX_FLAGS=-DUSE_64_BIT=1, 21, , 64-bit-versions, ubuntu-latest-amd64) (pull_request) Successful in 3m35s
CI / test (amd64, -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, 21, , gcc, ubuntu-latest-amd64) (pull_request) Successful in 3m31s
CI / test (amd64, -DUSE_SIMD_FALLBACK=ON, 21, , simd-fallback, ubuntu-latest-amd64) (pull_request) Successful in 3m36s
CI / release (amd64, -DMSAN_TOOLCHAIN_PATH=/opt/msan, ubuntu-latest-amd64) (pull_request) Successful in 6m0s
CI / coverage (pull_request) Successful in 4m1s
ae5bd27d18
`newestVersion - 2e9` is evaluated in `double`, whose 53 bit mantissa
makes the `newestVersion - 2000000000` boundary off by up to 512 versions
once `newestVersion >= 2^53`. skip_list therefore reported `Commit` for
reads one version below the window, and `TooOld` for reads exactly at it.
`ReferenceImpl` in Internal.h had the same expression, so the differential
tests could not catch it.

Share a single integer `kNominalVersionWindow` via Internal.h, use it in
both places, and drop the duplicate (already integer) definition from
ConflictSet.cpp. Adds a regression test that bisimulates skip_list against
the radix tree above 2^53.

Closes #99
All checks were successful
CI / test (arm64, -DCMAKE_BUILD_TYPE=Debug -DMSAN_TOOLCHAIN_PATH=/opt/msan, 22, https://minio.weaselab.dev/public/aarch64/msan-toolchain-22.1.8.tar.zst, debug-arm64, ubuntu-latest-arm64) (pull_request) Successful in 3m54s
Required
Details
CI / release (arm64, , ubuntu-latest-arm64) (pull_request) Successful in 4m26s
Required
Details
CI / pre-commit (pull_request) Successful in 2m14s
Required
Details
CI / test (amd64, -DCMAKE_BUILD_TYPE=Debug -DMSAN_TOOLCHAIN_PATH=/opt/msan, 21, https://minio.weaselab.dev/public/x86_64/msan-toolchain-21.1.8.tar.zst, debug, ubuntu-latest-amd64) (pull_request) Successful in 4m1s
Required
Details
CI / test (amd64, -DCMAKE_CXX_FLAGS=-DUSE_64_BIT=1, 21, , 64-bit-versions, ubuntu-latest-amd64) (pull_request) Successful in 3m35s
Required
Details
CI / test (amd64, -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, 21, , gcc, ubuntu-latest-amd64) (pull_request) Successful in 3m31s
Required
Details
CI / test (amd64, -DUSE_SIMD_FALLBACK=ON, 21, , simd-fallback, ubuntu-latest-amd64) (pull_request) Successful in 3m36s
Required
Details
CI / release (amd64, -DMSAN_TOOLCHAIN_PATH=/opt/msan, ubuntu-latest-amd64) (pull_request) Successful in 6m0s
Required
Details
CI / coverage (pull_request) Successful in 4m1s
Required
Details
You are not authorized to merge this pull request.
This pull request can be merged automatically.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u https://git.weaselab.dev/weaselbot/conflict-set weaselbot/issue-99:weaselbot-weaselbot/issue-99
git checkout weaselbot-weaselbot/issue-99
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: weaselab/conflict-set#102