base: make heavy tests pass under sanitizers; fix latch_test data race#206
Merged
Conversation
Running `flare/base/...` under `--sanitizer=thread` surfaced one test-side data race and three tests too heavy to finish under instrumentation: - latch_test: `TEST(Latch, Torture)` runs `RunTest` on 10 threads, each ending with `std::cout << ...`; concurrent formatted output races the stream buffer. Serialize that line with a mutex. - spinlock_test: 100 threads x 100k contended lock cycles -- under a sanitizer each contended acquire spins an unbounded, instrumented number of times, so the run takes many minutes (well past the test timeout). The brute-force volume is the race detector in a non-sanitized build, so keep it there and scale down (8 threads x 2k) only under ASan/TSan, following the existing `scheduling_group_test` pattern (FLARE_INTERNAL_USE_ASAN/TSAN). - compression_test / view_test: their 10 MiB workloads (LargeSize, VariantSize's ~9.5k-size sweep, the noncontiguous-buffer searches) are slow to instrument and time out under parallel sanitizer runs. These are large-data, not brute-force-race, tests, so just shrink them unconditionally to sizes that still exercise the multi-block / cross-block paths (512 KiB, ~1 MiB, a coarser size sweep). The 2 GiB extreme stays covered by DISABLED_HugeSize. Verified: `flare/base/... --sanitizer=thread` is all green; the normal build is unaffected (full-size workloads still run there, except the unconditionally shrunk compression/view).
spinlock_test.cc now includes flare/base/internal/annotation.h (for the ASan/TSan workload guard); the blade BUILD got the dep but the Bazel build needs it too.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Running
flare/base/...under--sanitizer=threadsurfaced one test-side data race and three tests too heavy to finish under instrumentation. (The DPC library race is fixed separately in #205.)Changes
latch_test— real data race (fixed for all builds).TEST(Latch, Torture)runsRunTeston 10 threads, each ending withstd::cout << ...;std::coutisn't safe for concurrent formatted output, so the threads race its buffer (TSan: race in__pad_and_output). Serialized with a mutex.spinlock_test— gated scaling. 100 threads × 100k contended lock cycles: under a sanitizer each contended acquire spins an unbounded, instrumented number of times, so the run takes many minutes (was literally unrunnable — 360s+). The brute-force volume is the race detector in a non-sanitized build, so it's kept at full strength there and scaled to 8 × 2k only under ASan/TSan — following flare's existingscheduling_group_testpattern (FLARE_INTERNAL_USE_ASAN/TSAN).compression_test/view_test— unconditional shrink. Their 10 MiB workloads (LargeSize,VariantSize's ~9.5k-size sweep, the noncontiguous-buffer searches) are slow to instrument and time out under parallel sanitizer runs. Unlike spinlock these are large-data tests, not brute-force race hunts, so they're simply shrunk everywhere to sizes that still exercise the multi-block / cross-block paths (512 KiB, ~1 MiB, a coarser size sweep). The 2 GiB extreme stays covered byDISABLED_HugeSize.Verification
flare/base/... --sanitizer=thread: all green (93/93), including parallel execution