Files
Martin Vogel 15292e2b25 test(subprocess): sample one process tree idle and loaded
subprocess_tree_rss_measures_contained_descendants compared two
independently spawned process trees, one idle and one whose descendant
touched 128 MiB, and required the loaded total to be at least 96 MiB
above the idle total. Two separate trees need not start from the same
footprint. On the hosted Windows CLANG64 leg they did not: the loaded
tree measured only 78 MiB above the idle one (167 MiB vs 245 MiB), and
the test failed on two unrelated PRs within two days (#2965 on
889170ca, #2975 run 43499140720). The diagnosis that the two separate
trees are the cause comes from #2965.

The test now samples ONE tree twice, and every wait in the handshake is
a blocking pipe read instead of a poll of a ready file:

- The test creates two pipes, "up" (tree to test) and "down" (test to
  tree): FIFOs in its private temporary directory on POSIX, named pipes
  named after that directory's unique leaf on Windows. The
  __cbm_rss_tree_root role connects both as its first action and starts
  one __cbm_rss_tree_hold descendant that inherits the connected ends
  (fork on POSIX, an explicit two-handle inherit list on Windows); the
  root then drops its own copies.
- The descendant writes 'I'; the test takes the idle sample and writes
  'L'; the descendant touches every page of a 192 MiB load and writes
  'R'; the test takes the loaded sample and closes its ends, which
  releases the descendant to free the load and exit.
- A descendant that dies closes its ends, so the waiting read returns
  end-of-file instead of blocking. No handshake step has a sleep, a poll
  interval or a deadline.

The floor stays at 96 MiB and is now half the load: the root does not
grow between the two samples, so a probe that counts only the root
misses the floor by 96 MiB, and a probe that counts the descendant
clears it with 96 MiB to spare. The two member-fault tests use the same
handshake and keep their assertions. Production code is unchanged.

Evidence:
- macOS arm64, ASan: subprocess suite 60 passed, 2 skipped (the
  Windows-only Job Object probes); the rewritten test passed 20 of 20
  consecutive runs, idle 43 MiB and loaded 259 MiB in every run.
- Binding: with the macOS probe temporarily limited to the root process,
  the test fails at the floor assertion (idle 33 MiB, loaded 33 MiB);
  restoring the probe returns the suite to green.
- Linux arm64 container, gcc ASan: subprocess suite 60 passed,
  2 skipped; the rewritten test passed 20 of 20 consecutive runs, idle
  462 MiB and loaded 654 MiB in every run.
- Windows: both changed files compile with -fsyntax-only -Wall -Wextra
  -Werror under llvm-mingw for x86_64 and aarch64.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-14 14:03:21 +01:00
..