From e7c59a026b182a05bc879cb3ccb107ebadfd52af Mon Sep 17 00:00:00 2001 From: Alberto Balbo Date: Wed, 4 Nov 2026 10:12:43 +0100 Subject: [PATCH] test(decode): wait for the read-ahead before the demand loads that must meet it ADemandLoadWaitsForTheReadAheadOfADevelopingWindow counted on the read-ahead starting on the thread pool before the next frames were asked for. On a busy runner it had not begun, only the four demanded frames were decoded, and the rc.8 release and main's PostgreSQL 16 job failed on 'Decodes > 4'. The test now waits, within the CI time budget, until the read-ahead develops a frame of its own; the one-development limit it checks is unchanged. Co-Authored-By: Claude Opus 5.5 --- .../Processing/DecodeParallelismTests.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/Chronos.Data.Tests/Processing/DecodeParallelismTests.cs b/tests/Chronos.Data.Tests/Processing/DecodeParallelismTests.cs index b9dbb3a3..a5ee7d80 100644 --- a/tests/Chronos.Data.Tests/Processing/DecodeParallelismTests.cs +++ b/tests/Chronos.Data.Tests/Processing/DecodeParallelismTests.cs @@ -118,7 +118,17 @@ public sealed class DecodeParallelismTests await using (var source = new SequenceFrameSource(frames, frames.LightFrames(), new ImageDecoder([decoder]), window)) { Assert.Equal(1, source.DevelopingLimit(1920, DecodePurpose.Render)); - foreach (var index in new[] { 0, 2, 4, 6 }) + using (await source.GetFrameAsync(0, 1920, DecodePurpose.Render, CancellationToken.None)) { } + // The read-ahead starts on the thread pool; on a busy runner it may not have begun before the next frames are + // asked for, and then nothing would race. Wait until it develops a frame of its own, so the demand loads below + // always meet a developing read-ahead. + var started = DateTime.UtcNow; + while (decoder.Decodes < 2) + { + Assert.True(DateTime.UtcNow - started < TimeSpan.FromSeconds(TestTiming.Budget(10)), "the read-ahead never started"); + await Task.Delay(5); + } + foreach (var index in new[] { 2, 4, 6 }) using (await source.GetFrameAsync(index, 1920, DecodePurpose.Render, CancellationToken.None)) { } } Assert.Equal(1, decoder.Peak); -- 2.54.1