Test inspect_memory_rollup_json_matches_legacy_under_churn fails under cargo test: parser-pool bytes not removed (main)
On main, subc::health::tests::inspect_memory_rollup_json_matches_legacy_under_churn fails when other tests run at the same time in the same process. The test builds the expected snapshot and then the actual snapshot. Each build reads the process-wide parser-pool total, and the test does not remove that term before it compares the two totals. If a different test thread gets parsers or ends between the two builds, the totals are different by a small constant.
Results
Commit cd823af91, Linux, cargo test -p aft-subc --lib, with the default test threads:
| Full-suite run | Result at health.rs:9848 |
actual (built second) |
expected (built first) |
Difference |
|---|---|---|---|---|
| 1 | fail | 3530880 | 3530800 | +80 |
| 2 | pass | |||
| 3 | fail | 3663085 | 3663005 | +80 |
| 4 | fail | 3556997 | (not kept) | |
| 5 | fail | 3490868 | 3490948 | −80 |
- The size of the difference is always 80 bytes. The sign changes, so it is not a constant bias in one build.
- The test passes 10 times out of 10 when it runs alone (
-- --exact). - Upstream CI passes at the same commit. Nextest runs each test in its own process, so no different test can change the parser pools between the two builds.
Cause
root_and_shared in the test (crates/aft-subc/src/subc/health.rs:9843-9847 on main c89102de2) removes sqlite.memory_used_bytes and embedding_model_bytes from total_attributed_bytes. These two terms are process-wide, and the test knows that they can change.
Commit 2ad367f31 (2026-11-24) added a third process-wide term to total_attributed_bytes in process_from_root_rollups: reusable_parser_pools_memory(). That function reads the global TOTALS in crates/aft-parse/src/parser/reusable.rs, which is threads * size_of::<ParserPool>() + parsers * size_of::<(LangId, Parser)>(). The total goes up when a thread puts a parser in its pool, and it goes down when that thread ends (impl Drop for ParserPool).
Commit ed4a48bda added the test on 2026-10-26, before this term, and the test does not remove the term. Thus a different test thread that starts or ends parser work between the two builds changes the compared value. That agrees with a constant size and a sign that changes. The release tags v0.68.0 and v0.68.1 do not contain 2ad367f31.
Possible repair
In root_and_shared, also remove the parser-pool bytes. Or make the test read the shared process terms one time and use them for the two builds.
Thanks, @iceteaSA. Your diagnosis is right: the test compares two snapshots after removing the process-wide terms other threads can change, and the parser-pool bytes added on 24 November weren't removed, so under plain cargo test another test's parser pool can move the total by a small constant between the two builds. Nextest runs each test in its own process, which is why our CI didn't catch it.
The fix follows your suggestion: the test now also subtracts the parser-pool bytes read from each snapshot, the same number the rollup adds. It's test-only, in #1566. With default test threads, the test passed 6 of 6 full-suite runs on Linux. It will close once that merges.