Skip to content

Assert profile-path attribution on call counts, not elapsed time - #128

Merged
revarbat merged 1 commit into
mainfrom
fix-flaky-profile-test
Aug 28, 2026
Merged

Assert profile-path attribution on call counts, not elapsed time#128
revarbat merged 1 commit into
mainfrom
fix-flaky-profile-test

Conversation

@revarbat

Copy link
Copy Markdown
Member

ProfilePaths.SameCalleeUnderTwoCallersGetsSeparateNodes failed a macOS CI run and blocked the merge of #127.

It is a genuine flake

The assertion compared elapsed time of the same callee under a light and a heavy caller:

EXPECT_GT(workUnderHeavy->cumulativeTime, workUnderLight->cumulativeTime);

heavy does ~10× the work, so the ratio is normally ~9×. Measured over 15 runs it collapsed as low as 1.79× — and on a shared CI runner it can cross 1.0. Wall clock is not something to assert an ordering on when an exact quantity is available.

Confirmed by re-running the identical commit: it passed.

The exact quantity was already there

I first tried callCount on the node itself — 1 for both, because recursion folds. Measuring the actual tree showed where the difference lives:

--- light subtree ---        --- heavy subtree ---
work  calls=1                work  calls=1
  work  calls=2                work  calls=20

The folded recursion child carries it: 2 against 20, identical on both engines. That is a stronger statement of what the test exists to prove — each path carries its own attribution — and it cannot invert.

Times are still asserted, but only for existence, which is all that is deterministic about them.

Checked while here

No other assertion in the file compares timings between two workloads. The rest are >= 0, > 0, or cumulative >= self — structural, not races.

60 runs across both engines, no failures. 1078 tests pass.

Version 0.51.1 → 0.51.2.

🤖 Generated with Claude Code

ProfilePaths.SameCalleeUnderTwoCallersGetsSeparateNodes compared the
cumulative TIME of the same callee under a light and a heavy caller.
That failed a macOS CI run and blocked a merge.

It is a genuine flake, not a symptom of anything: heavy does about ten
times the work of light, so the ratio is normally around 9x -- but
measured over 15 runs it collapsed as low as 1.79x, and on a shared
runner it can cross 1.0. Wall clock is not something to assert an
ordering on when an exact quantity is available.

The exact quantity was already there. Recursion folds onto a child
node, and that child carries the call count: 2 under light against 20
under heavy, identical on both engines. That is a stronger statement of
the property the test exists for -- each path carries its own
attribution -- and it cannot invert.

The times are still checked, but only for existence, which is all that
is deterministic about them.

Checked while here: no other assertion in the file compares timings
between two workloads. The rest are >= 0, > 0, or cumulative >= self,
which are structural.

60 runs across both engines, no failures. 1078 tests pass.
@revarbat
revarbat merged commit 25db518 into main Aug 28, 2026
3 checks passed
@revarbat
revarbat deleted the fix-flaky-profile-test branch August 28, 2026 01:32
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.

1 participant