Skip to content

#296 Test suite cleanup: cut wall-time, fix variance, add per-fixture test-affected tooling - #301

Merged
nockawa merged 1 commit into
mainfrom
feature/296-test-cleanup
May 4, 2026
Merged

nockawa merged 1 commit into
mainfrom
feature/296-test-cleanup

Conversation

@nockawa

@nockawa nockawa commented May 4, 2026

Copy link
Copy Markdown
Collaborator

Closes #296.

Summary

  • Wall-clock: 31.6 s → 28.1 s avg (−3.5 s, ≈ 11 %; CPU sum −14 s, ≈ 24 %)
  • Variance bomb defused: ExceptionPathLeakTests.GetRevisionElement_WhenLockTimeout was 78 ms ↔ 5 039 ms (1 of 3 runs spiked); now deterministic at ~80 ms
  • Iteration tooling: scripts/test-affected.py resolves edited files → fixture set via coverage/test-affected-map.json; focused edits run in ~1.7 s vs 30 s for the full suite (18× speedup on the typical iteration loop)

What's in the diff

1. Phase 1 — [Explicit] 6 Report_* benchmarks in Runtime/DagSchedulerCpuTests.cs and Runtime/DagSchedulerLatencyTests.cs. They were CPU/latency measurements over multi-second windows, not regression assertions.

2. Phase 2.1 — OlcBTree concurrency-test diagnostics. Replaced int errors + Interlocked.Increment(ref errors) with ConcurrentBag<Exception> + exceptions.Add(ex) in 5 OlcBTree concurrent tests; assertion message now dumps the first exception's full stack. Already paying off — surfaced a real OLC concurrency bug pattern (workers don't throw, but a key is missing on read-back) → filed as #297.

3. Phase 2.2 — [NonParallelizable] on ExceptionPathLeakTests and TransactionUnitOfWorkContextTests. Root cause: TimeoutOptions.Current is a process-global static; every parallel DatabaseEngine ctor overwrites it, racing the test's own override. Filed proper architectural fix as #298.

4. Phase H — Heavy-test optimization (36 tests, 14 files):

  • LockTest: 10 000 → 2 000 iterations (32 threads × 2 000 = 64 000 ops still ample for race detection)
  • ReliabilityTest: 25 frames × 1 000 ops → 10 × 500
  • TransactionChain.Stress_ConcurrentCreateDispose: 200 ms → 50 ms hold
  • ConcurrentBitmapL3 stress: 5 000 → 2 000 ops/thread
  • WAL_ManyEntities_SurvivesReopen: 500 → 100 entities
  • 12 lock-timeout tests (AccessControlSmallTests / ResourceAccessControlTests): 100 ms → 30 ms
  • 8 timer-interval tests (HighResolutionSharedTimerServiceTests): Stopwatch.Frequency / 10 (100 ms tick) → /100 (10 ms) — these tests verify register/dispose semantics, not interval correctness
  • ChunkBasedSegmentBitmapL3Tests.ClearL0_MultipleGroups_BitmapConsistency: List<int>.Contains → HashSet<int>.Contains (was O(n²) on hundreds of chunks)
  • Dropped redundant CreateAndLoadBigSegment(4500) (kept 5 000)

5. Phase T — Test-selection tooling (scripts/test-affected.py, scripts/build-test-affected-map.py, coverage/test-affected-map.json):

  • 366 src files mapped (median 4 fixtures/file). 214 files (58 %) → ≤ 5 fixtures (clean local-edit fast path); 80 files (22 %) → full-suite fallback (genuinely cross-cutting primitives like PagedMMF, AccessControlSmall).
  • Two-layer cache (cobertura XML + parsed-JSON sidecars). Builder is incremental: 0.3 s no-change, ~5 s per touched test file. --force for refactor-time full rebuild.
  • CLAUDE.md updated with the new default workflow.

Follow-ups (already filed)

Test plan

  • Full suite passes (3 fresh Release runs post-everything: 27.5 / 28.3 / 28.6 s).
  • scripts/test-affected.py validated end-to-end on local-edit, cross-cutting, multi-file, and no-match fallback cases.
  • Incremental map builder verified: 0.3 s no-change, ~5 s after touching one test file.
  • Variance test goes from 5 039 ms → ~80 ms deterministic.
  • OlcBTree diagnostic refactor verified — surfaced a previously-masked failure mode (filed as OLC: concurrent inserts can lose keys under contention without throwing #297).

Doc PR

Companion changes in the claude/ submodule on the same branch: research doc moved scratch → research, new design doc for the tooling. PR opened separately in nockawa/typhon-claude.

🤖 Generated with Claude Code

@nockawa
nockawa merged commit b8b92c8 into main May 4, 2026
5 checks passed
@nockawa
nockawa deleted the feature/296-test-cleanup branch May 4, 2026 21:00
nockawa added a commit that referenced this pull request May 27, 2026
- BulkLoad write path (P1-P5): opt-in throughput API skipping per-row WAL via BulkBegin/BulkEnd manifest pair; new BulkLoadSession + recovery.
- Engine ALC lifecycle fix: ArchetypeRegistry refcounts per-engine, releases Type refs on dispose so collectible session ALCs can GC-unload.
- Workbench Data Browser (read-only) + non-generic entity access surface on the engine.
- File Map per-kind rendering: dbmap colour scheme, L0 ordering, hit-test, metrics, scale tests.
- CP-04 / #301 hardening: ChunkBasedSegment AllocateChunk/FreeChunk use ChangeSet-tracked IncrementDirty + new CP-04-safe accessor overload.
- ChunkBasedSegment.Grow capped-doubling at 1024 pages: avoids catastrophic single-allocation requests at scale.
- BitmapL3.SetL1 CAS fix: replaced non-undoable Interlocked.Or with CompareExchange; eliminates orphan-bit leak on partial-collision.
- LogicalSegment.Grow patches OLD tail's NextRawDataPBID: chain is now an actively-maintained invariant, not vestigial dead code.
- EnsureDirtyAtLeast(2) on every CreateOrGrow write path: closes the lost-write window when callers pass null ChangeSet.
- Chain<->Directory cross-check at LogicalSegment.Load: throws with precise diff on mismatch; loud detector for lost-writes.
- CheckpointManager shutdown fixes: unconditional final cycle (no LSN gate) + removed _shutdown early-exit that skipped fsync.
- DatabaseEngine.RunStorageIntegrityCheck + StorageIntegrityReport: audit API for popcount canary, chain/dir check, chunk-segment capacity invariant.
- PagedMMF short-disk-read defensive Debug.Assert against stale bytes in cache slot from partial reads.
- Workbench fixture: directory-per-database layout + Dev Fixture useBulkLoad toggle + stale dockview-API cleanup on session close.
- Tests: BulkLoadReopenIntegration, UnknownPagesDiagnostic, BulkLoadRecovery, BulkLoadWrite, BulkManifest, BitmapL3FreeRange, ArchetypeRegistryLifecycle.
nockawa added a commit that referenced this pull request Oct 9, 2026
…otected nothing (PR #1249)

ChangeSet.RegisterReDirty is gone. Its five call sites (ChunkAccessor.MarkSlotDirty, ChunkBasedSegment.AllocateChunk and TryReserveChunk, LogicalSegment.InitDataPages and the map-page path of CreateOrGrow) call only AddByMemPageIndex, and the per-page count map becomes a set. The extra mark served a checkpoint that decremented DirtyCounter. Since #824 the checkpoint never touches the counter, a set keeps its first mark on a page until ReleaseDirtyMarks clears it, and every reader tests only == 0 or > 0. A re-dirty's write obligation is the WritebackGen bump AddByMemPageIndex makes on a page it already tracks (CP-04). The removed bump was always the second of two adjacent ones, with no write between them. MarkSlotDirty no longer pays a dictionary update and two Interlocked operations per re-dirty.

Thirteen source files described a DirtyCounter floor of 2, release capping at 1, or a checkpoint DecrementDirty; they now describe marks released in full and writeback debt. PS-05 and CP-04 drop RegisterReDirty, PS-01's eviction predicate includes writeback debt as TryAcquire does, and PS-05a and PS-08 name what the code uses. doc/in-depth-overview/02-storage.md follows.

Five independent reviews found no regression: eviction sees DC == 0 at the same instants, the five sites are race-free on x64 and arm64, and #385, #301 and #824 cannot recur. A stress A/B against main was clean. Mutation testing found two Release-gate blind spots: an over-release on a co-owned page, and an allocation not followed by a write on its page (#301). ChangeSetCallSiteRecordingTests pins both and is named in CP-04 and PS-05. Gate-parity run: 7931 tests, 0 failures.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test suite cleanup: cut wall-time, fix variance, add per-fixture test-affected tooling

1 participant