Repository navigation
Make the two allocation tests deterministic: read their rows from the existing TypedReader - #136
Merged
Merged
Conversation
… boxes an int per row The two allocation tests compared bytes measured back to back through a DataTableReader, whose GetInt32 boxes each value (24 B per row). Tiered JIT removes that box part way through a measurement, so one side of a comparison could be 24 B per row cheaper than the other and the test failed at random. An ArrayReader serves typed getters straight from int[]/long[]/string[], so the measured bytes are the library's own at every tier. The thresholds, the warm-up and the tests' claims are unchanged. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ArrayReader TypedReader already serves typed getters over cells boxed once when the rows are built, so a row read allocates nothing; ArrayReader duplicated it. Ints and Rows now build a TypedReader. Thresholds and assertions are unchanged. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make the two allocation tests deterministic by reading their rows from the existing
TypedReaderinstead of aDataTableReader, which boxed an int per row and made them fail at random.The fixture read ints through
DataTableReader.GetInt32, which allocates a 24 B box per row. Tiered JIT removes that box part way through a run, so when it lands between the two back-to-back measurements ofMappedQuerySelectTests.TheAsyncProjection_AllocatesNothingPerRoworSingleValueAllocationTests, one side is 24 B per row cheaper and the comparison fails; the library allocates nothing per row.What changed
Ints(inMappedQuerySelectTests) andRows(inSingleValueAllocationTests) build aTypedReader(TypedReader.CreatewithColumnDefcolumns) instead of aDataTableandDataTableReader. The cells are boxed once, when the rows are built, outside the measured region; the typed getters only unbox them, so a row costs nothing.Source/is touched.ArrayReader; the second removes it in favor of theTypedReaderthe test project already has (the net result is only the two helper changes).Verification
TheAsyncProjection_AllocatesNothingPerRow, net11.0 Release, filtered, 10 runs: 10 of 10 passed.SingleValueAllocationTests, net11.0 Debug, class alone, 10 runs: 10 of 10 passed (12 tests each).ToListAsync, plain vs projected): 8.0 B per row for both (8712 B plain and 9032 B projected at 1,000 rows; 1472 B and 1792 B at 100), the same filtered, with tiered compilation off, and inside the full run. The projection adds a flat 320 B per call and the 24 B per row gap is gone.TheAsyncProjection_AllocatesNothingPerRowfails ("costs 2720 B per call over 100 rows and 24320 B over 1000"); with one in the single-value mapper, 4 of the 12SingleValueAllocationTestsfail (for example "ToArray over 100 rows: 2864 B per call through the terminal, 488 B by hand"). Both changes were reverted and never committed.Not done
RowMapConverterTests.AConverter_AllocatesNothingBeyondItself_PerRowstill reads through aDataTableReaderand compares bytes of two calls (a converter against none), so it has the same exposure in principle; it did not fail in any run here.AllocationQuickWinTestsalso usesDataTableReaderbut only as a positioned record.🤖 Generated with Claude Code