Skip to content

Tests: wall-clock assertions flake on the shared CI runner #400

Closed

Description

@Tim81

Two tests assert on wall-clock time and failed on GitHub's shared runner on 2026-09-02 without any change to the code they measure.

EncryptDictionaryDenialOfServiceTests.HugeEncryptDictionary_opensUnderTimeout

tests/VellumPdf.Reader.Tests/EncryptDictionaryDenialOfServiceTests.cs:48, [Fact(Timeout = 10_000)], the #208/#215 regression pin. Cancelled at the timeout on two consecutive runs of the fix/kernel-encrypt-p-bit10 branch (#399), which touches neither the reader nor this test:

  • run 33672982347 at 9390847: failed (canceled) (10s 129ms)
  • run 33675987457 attempt 1 at eb0ce36: failed (canceled) (10s 012ms)

Attempt 2 of the second run passed with no code change, and the next push (0626bb1) passed first time. The same test takes 0.33 s in a Release build on the development machine, so the runner was at least thirty times slower for that one test. The likeliest reason is contention rather than a slow runner: the Reader assembly's classes run in parallel, and ParserFuzzTests (CsCheck, which uses every core) runs in the same assembly, so a test that allocates a 100 000-key dictionary can be starved while the fuzzer is mid-sample.

The class doc explains why the Timeout is there: pre-#215 the quadratic copy took two to three times the budget, and the timeout is what proves the fix. A time budget on a shared runner cannot prove that reliably. Options, in order of preference:

  1. Replace the wall-clock pin with a scaling pin: open the document at 20 000 and at 100 000 filler keys and assert the second takes less than, say, eight times the first (linear would be five, quadratic twenty-five). Both measurements suffer the same contention, so the ratio is stable where the absolute time is not.
  2. Keep the absolute budget but mark the class [Collection]-isolated or DisableParallelization, so it does not share cores with the fuzzer. This still fails on a slow runner, only less often.
  3. Raise the budget. This weakens the pin (the pre-fix cost was two to three times the budget) and still fails on a bad day.

PageTreeTests.ManyDistinctEmptyNodes_stopsAtTheKidsExaminedBudget_withNoCycleInvolved (#398, not yet merged)

Assert.True(stopwatch.Elapsed < TimeSpan.FromSeconds(30)) over a walk of 1 000 001 indirect page-tree nodes. Ran 51.8 s at 093709a and 32.9 s at 6a03b6f on the runner, passed at b6f2785. Being fixed inside #398 by building the nodes as direct dictionaries (one parse pass, no per-object resolve) and dropping the wall-clock assertion; recorded here so the two are seen as one problem.

Sweep

grep -rn "Timeout = \|Stopwatch\|TimeSpan.FromSeconds" tests/ for the remaining wall-clock assertions and apply the same reasoning to each: a time budget is only a regression pin if the pre-fix cost exceeds it on the slowest machine the suite runs on, and the shared runner has now shown that its slowest is a lot slower than the development machine.

Activity

  1. added
    area/ci
    type/chore
    on Sep 2, 2026
  2. Tim81 commented on Sep 9, 2026

    @Tim81
    OwnerAuthor

    Adding a cause this issue does not currently name: contention between Claude sessions, not just within one assembly.

    The issue attributes the flake to ParserFuzzTests taking every core inside VellumPdf.Reader.Tests, which is real. But on 2026-09-09 this machine was running three Claude sessions at once, one of them executing mutation passes across four worktrees — each pass a rebuild plus a full suite, one of them covering 41 mutants — while another ran full oracle suites elsewhere. The user reported the machine pegged at 100% for an extended period. Capping build and test parallelism brought it to 14%.

    Nobody sized a ten-second budget against that load profile, and it is invisible from inside any one session: each session's own work looks reasonable on its own.

    Two measurements worth having on the record here:

    • On CI the Reader assembly took 6m 21s against 34s locally, roughly eleven times slower, with seven assemblies running concurrently on a smaller runner.
    • A wall-clock assertion that passes on an uncapped local machine is therefore not evidence of anything. The margin it appears to have is measured under conditions neither CI nor a busy developer machine reproduces.

    This strengthens the case for option 1 in the issue body over option 3. It also argues against the intermediate design tried in #456, which compared two timings and asserted a ratio: under load the benign ratio reached 24.6 against 26.1 for the real defect, because taking the fastest of several samples drags a short measurement to its floor while a long one absorbs every preemption. #456 now raises the problem size instead, so a fixed budget separates linear from quadratic with margin on both sides.

    The five remaining tests using this pattern are all in VellumPdf.Kernel.Tests, plus one more in VellumPdf.Reader.Tests (ManyStreamsWithNoEolBeforeTheirOwnEndstream_DoesNotBecomeQuadratic) which shares a process with the fuzzer and has the same exposure. None has been seen to fail; none has had its margin measured.

  3. Tim81 commented on Sep 9, 2026

    @Tim81
    OwnerAuthor

    A third occurrence, with its run id, since the two in the body have theirs and this one did not.

    2026-09-08, run 34286930244, PR #446. EncryptDictionaryDenialOfServiceTests.HugeEncryptDictionary_opensUnderTimeout reported failed (canceled) (10s 061ms). That branch changes .github/workflows/docs-inventory.yml and CHANGELOG.md and no code at all, so it cannot have caused it. PR #445, which has far more in it, passed the same test in the run before.

    Two things found while sizing the replacement in #456, both of which change what the sweep should look at.

    The six absolute Timeout budgets all share a process with a CsCheck fuzzer, not just the one in the Reader assembly. Microsoft.Testing.Platform gives each test project its own process, and VellumPdf.Kernel.Tests references CsCheck and samples generators in PropertyTests at the default iteration count. The five budgets there are MalformedInputTests at three sites and PdfDictionaryIndexTests at two. ParserFuzzTests in the Reader assembly is the heavier of the two: FuzzBudget.DefaultIterations is 3,000 against CsCheck's default of 100, and five more classes in that assembly sample at the same budget.

    The two in PdfDictionaryIndexTests are the highest-value target. They are the other half of this same #208 pin, they carry 140,000 keys under ten seconds, and they were sized by the same local reasoning that mispredicted the runner here. Neither has been measured on a runner.

    Cross-session contention is a cause the budget was never sized against. Several agent sessions share this development machine and each assumes it owns the cores. A local timing taken while another session was building is not the number a budget should be set from, in either direction.

    One correction to this issue's own body: it puts the pre-fix overrun at two to three times the ten-second budget. Remeasured in #456 at 100,000 keys it is 3.4 times, from 34 s of open cost with the dictionary index disabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/citype/chore

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions