From 83b592f76ff12b087b924a9247652037620a90f4 Mon Sep 17 00:00:00 2001 From: MPCoreDeveloper Date: Thu, 12 Nov 2026 22:22:16 +0100 Subject: [PATCH] test(allocation): set the InsertBatch ceiling from runner measurements (915 B/row) The per-OS ceiling was still wrong: the GitHub windows-latest runner measures 902 B/row while this developer box measures 894 on the same commit, and both Unix runners measure 903. So the spread is the environment's GC/JIT accounting, not the OS and not a code path - an absolute-bytes canary set on a developer machine fails every runner. One ceiling now covers all four environments: 915 B/row, above the highest runner figure (903) and below the pre-hoist 919 (about 927 on a runner), so reintroducing the allocation this canary was written to catch still fails everywhere. Measurements recorded in the test: dev box win-x64 894 (1.787.608 bytes), runner win-x64 902 (1.803.560), runner linux-x64 903 (1.806.872), runner osx-arm64 903 (1.806.856). Verified locally: the canary passes on win-x64 with the new ceiling. --- .../Net11/InsertBatchAllocationTests.cs | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/tests/SharpCoreDB.Tests/Net11/InsertBatchAllocationTests.cs b/tests/SharpCoreDB.Tests/Net11/InsertBatchAllocationTests.cs index 8998335b..3e18d19f 100644 --- a/tests/SharpCoreDB.Tests/Net11/InsertBatchAllocationTests.cs +++ b/tests/SharpCoreDB.Tests/Net11/InsertBatchAllocationTests.cs @@ -65,17 +65,20 @@ public void Dispose() public void InsertBatch_ArrayRows_AllocatesAtMostPerRow() { const int Rows = 2_000; - // Measured 2026-11-12 on the GA runtime (11.0.100) with this exact overload, same commit: - // win-x64 894 B/row (1.787.608 bytes / 2.000 rows) — after the presence-mask hoist - // linux-x64 903 B/row (1.806.872 bytes) - // osx-arm64 903 B/row (1.806.856 bytes) - // The 9 B/row delta between Windows and the Unix runners is the runtime's own accounting for the same - // code — the canary first ran on Windows only, so a single 900 ceiling failed both Unix jobs. An - // absolute-bytes canary has to carry the platform's own figure, or it reports a platform difference as - // a regression. The Unix ceiling stays ~1 % above its measured value and *below* the pre-hoist 919 - // B/row (+9 on Unix), so reintroducing the allocation this test was written to catch still turns it red. - // Before the hoist the figure was 919 B/row on Windows (1.838.776 bytes), a measured -25 B/row. - int ceilingBytesPerRow = OperatingSystem.IsWindows() ? 900 : 915; + // Measured with this exact overload on the GA runtime (11.0.100), same commit, dictionary-free + // object[] + column-order path: + // developer box, win-x64 894 B/row (1.787.608 bytes / 2.000 rows) + // GitHub windows-latest 902 B/row (1.803.560 bytes) + // GitHub ubuntu-latest 903 B/row (1.806.872 bytes) + // GitHub macos-latest (arm64) 903 B/row (1.806.856 bytes) + // The 894-903 spread is the environment's own accounting for identical code (GC and JIT-tiering + // behaviour, not a code path): the first single-environment ceiling of 900 was recorded on the + // developer box and failed *every* runner. The ceiling therefore sits above the highest runner + // figure and still below the pre-hoist 919 B/row (1.838.776 bytes, ~927 on a runner), so + // reintroducing the allocation this canary was written to catch still turns it red everywhere. + // Guardrail: absolute-bytes canaries must be set from the runner measurement, never from a + // developer machine — the same reason AGENTS.md says to quote ratios, not absolutes. + const int CeilingBytesPerRow = 915; // Warm the call shape first: a tiered-JIT promotion inside the measured call would be charged to it. db.InsertBatch("docs", BuildRows(0, 500), Columns); @@ -87,8 +90,8 @@ public void InsertBatch_ArrayRows_AllocatesAtMostPerRow() double perRow = allocated / (double)Rows; Assert.True( - allocated <= Rows * (long)ceilingBytesPerRow, - $"InsertBatch allocated {allocated:N0} bytes for {Rows:N0} rows ({perRow:F0} B/row); at most {ceilingBytesPerRow} B/row was expected."); + allocated <= Rows * (long)CeilingBytesPerRow, + $"InsertBatch allocated {allocated:N0} bytes for {Rows:N0} rows ({perRow:F0} B/row); at most {CeilingBytesPerRow} B/row was expected."); } private static List BuildRows(int start, int count)