Repository navigation
Tests: the allocation probes read a column of ints that does not box - #301
Merged
Merged
Conversation
SyncToListAllocationProbe failed now and then (the chain 2,800,784 bytes, the list that grows 1,049,704). The difference is exactly 24 bytes a row: a DataTableReader boxes each int it reads until the JIT has optimized the read, and the probe measured the chain before the list, so when the optimization landed between the two measurements the chain paid for the boxes and the list did not. The pool and the library were not involved. Both probes that read a DataTable (the synchronous ToList and the reader's ToArrayAsync and ToImmutableArrayAsync) now read an in-memory reader of one int column whose typed getter allocates nothing, as a provider's does, so the count no longer depends on when the JIT tiers up. The threshold is unchanged. Over 100,000 rows the same counts come out with default settings, with TieredCompilation off and with tier-up delayed (the chain 400,136 bytes, the growing list 1,049,032). 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.
Tests only.
SyncToListAllocationProbe(100,000 rows) failed now and then: the chain allocated 2,800,784 bytes against 1,049,704 for the list that grows. The gap is exactly 24 bytes a row: aDataTableReaderboxes eachintit reads until the JIT has optimized the read. The probe measured the chain first and the list second, so when the optimization landed between the two measurements the chain paid for the boxes and the list did not. The pool and the library were not involved.The fix
Both probes that read a
DataTable(the synchronousToList, and the reader'sToArrayAsyncandToImmutableArrayAsync) now read an in-memory reader of oneintcolumn,Int32ColumnReader, whose typed getter allocates nothing, as a provider's does. The count no longer depends on when the JIT tiers up. The threshold is unchanged. The reader is aTypedReaderover a column made once (Int32Column), so a call allocates only the reader.Checks
DOTNET_TieredCompilation=0and withDOTNET_TC_CallCountingDelayMs=2000:ToList400,136 bytes, the growing list 1,049,032,ToArray400,104. The asserting probes pass 3 of 3 under each of default,TieredCompilation=0,TieredPGO=0and a late tier-up.dotnet formatstyle and analyzers clean on all 28 checks, DocFX 0 warnings.Other allocation tests also read a
DataTableReader, but they assert a fixed bound on one measurement, not a comparison of two measured sides, so a tier-up between measurements does not flip them; none has flaked and they are left alone.🤖 Generated with Claude Code