From 73e724b3bba1221fa2906bda0460242b7c39a4ca Mon Sep 17 00:00:00 2001 From: Rafael Vuijk Date: Sun, 29 Nov 2026 23:52:55 +0000 Subject: [PATCH] Record coverage hits once on the Windows leg, where counting them slowed the suite threefold (#2671) The Windows leg of C# Test is the only one that runs the suite under coverlet. By default coverlet counts every sequence point it passes with an interlocked increment on one shared array, so tests running in parallel fight over the same cache lines. With the Calculus area pinned to four cores, as many as the runner has, the area took 315 s against 161 s without coverage. The integral of 1/(a + sin(x)) over [0, 2 pi] took 28 s against 10 s, and ln(x) erf(x) over [0, 1] took 58 s against 31 s. The first hit its 60 s timeout on Windows three times, and the second its 5-minute one twice (#2661). With SingleHit, coverlet records whether a line ran and not how often. The same run took 209 s, 10 s and 32 s, and the report visited the same 58,219 of 81,596 sequence points. The wall-clock budgets play no part. Neither integral runs a computation with a WorkBudget, and tightening every lid's clock to one tick leaves both times unchanged. The test's wall goes from 60 s to 120 s. Without #2662's cache the sine integral takes 190 s alone, so 120 s still fails on that regression and leaves the runner room. The reason is written in the test. Part of #2671. Part of #2661. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/CSharpTest.yml | 10 +++++++++- .../Calculus/ALimitAtABreakIsRememberedTest.cs | 9 ++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CSharpTest.yml b/.github/workflows/CSharpTest.yml index 8c087929f..980274f4f 100644 --- a/.github/workflows/CSharpTest.yml +++ b/.github/workflows/CSharpTest.yml @@ -66,12 +66,20 @@ jobs: # Simplify on the cubic row of RationalIntegralsTest recursed deeper than a 1 MB stack holds, # and the leg ran 2,094 to 8,507 of the tests. A Release build passes that row on 512 KB. # https://github.com/asc-community/AngouriMath/issues/397 + # + # SingleHit records whether a line ran, not how often. By default coverlet counts every hit + # with an interlocked increment on one shared array, and tests running in parallel then fight + # over the same cache lines. On four cores, as many as the runner has, that made the Calculus + # area take 315 s against 161 s without coverage. The integral of 1/(a + sin(x)) over + # [0, 2 pi] took 28 s against 10 s, and it hit its 60 s timeout on this leg alone. With + # SingleHit those were 209 s and 10 s, and the report visited the same 58,219 sequence points. + # https://github.com/asc-community/AngouriMath/issues/2671 - name: Test if to send if: ${{ matrix.os == 'windows-latest' }} shell: bash run: | cd Sources/Tests/UnitTests - dotnet test -c Release --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover + dotnet test -c Release --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.SingleHit=true cd ../../Utils/Utils dotnet run CopyCovReport diff --git a/Sources/Tests/UnitTests/Calculus/ALimitAtABreakIsRememberedTest.cs b/Sources/Tests/UnitTests/Calculus/ALimitAtABreakIsRememberedTest.cs index 7c6e80017..cbb4e0032 100644 --- a/Sources/Tests/UnitTests/Calculus/ALimitAtABreakIsRememberedTest.cs +++ b/Sources/Tests/UnitTests/Calculus/ALimitAtABreakIsRememberedTest.cs @@ -25,13 +25,20 @@ namespace AngouriMath.Tests.Calculus [Trait("Area", "Calculus")] public sealed class ALimitAtABreakIsRememberedTest { + /// + /// The wall sits between the two behaviours on the desktop. Alone, the sine integral takes 6 s with the + /// limits remembered and 190 s without them. In the Calculus area on four cores it takes 10 s. The wall was + /// 60 s, and it fired on the Windows runner, the one leg that ran under coverlet's counting of hits, where the + /// same run took 28 s. 120 s leaves that leg room and still fails on the 190 s regression. + /// https://github.com/asc-community/AngouriMath/issues/2671 + /// [Theory] [InlineData("1/(a + sin(x))", "0", "2 pi")] [InlineData("1/(a + cos(x))", "0", "pi")] public void AParametricIntegralAcrossAPoleIsLeftUnevaluatedInTime(string integrand, string from, string to) { var task = Task.Run(() => integrand.ToEntity().Integrate("x", from.ToEntity(), to.ToEntity()).Simplify()); - Assert.True(task.Wait(TimeSpan.FromSeconds(60)), $"{integrand} over [{from}, {to}] did not finish"); + Assert.True(task.Wait(TimeSpan.FromSeconds(120)), $"{integrand} over [{from}, {to}] did not finish"); Assert.Contains(task.Result.Nodes, node => node is Integralf); }