Repository navigation
Conversation
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-collections |
Contributor
|
Tagging subscribers to this area: @jaredpar, @333fred |
Open
3 tasks
Member
|
As mentioned in the README for this library, it is effectively archived and we are not accepting new contributions at this time. |
This was referenced Nov 16, 2026
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.
For batches of 16 collections with 65,536 items each, mean
Clear()time fell by 99.43-99.45% forintand 99.98% for a 64-byte value type in two BenchmarkDotNet comparisons.This follows #136605.
Clear()now sets the count to zero without clearing the array whenTcontains no object references.RemoveAt()also skips clearing the unused last slot. This matchesList<T>. New items overwrite these slots before use. Types that contain references, including structs, are still cleared.Performance
Selected
ClearBench<T>.ClearOnlyresults for 16 collections per batch. Setup and validation are outside timing. Times are microseconds (us) per batch, shown as mean +/- sample standard deviation for each process.intintWideWideBenchmarkDotNet
0.16.0-preview.2,InProcessEmitToolchain, verified High process priority. Each version ran in two fresh processes. Clear-only used 10 warmups and 100 measurements. Clear-and-refill and removal used 8 warmups and 30 measurements targeting 500 ms each.Windows 11 Pro x64 (build 26200), Ryzen 9 5950X, Release
.NET 12.0.0-dev. ReadyToRun and tiered compilation were disabled; concurrent workstation GC was enabled.Clear-only iterations were shorter than BenchmarkDotNet recommends, and some results had multiple timing clusters. All samples are included. These comparisons do not establish statistical significance. The
intremoval benchmark was slower in the first process pair and faster in the second. Some reference-containing Clear-only runs were also slower.Validation
System.Linq.Expressions.Testsbuilt from22c8eb4b0ecpassed 35,119 tests. Tests ran on the isolated benchmark runtime image with the matching collection implementation. No failures.ReadOnlyCollectionBuilder_RemoveAtchecks remaining contents and bounds after first, middle, and last removal.ReadOnlyCollectionBuilder_Clear1andReadOnlyCollectionBuilder_Clear2check the count after clearing populated and empty builders.Clear_AfterRemoval_DoesNotExposeOldItemschecks that enumeration andToReadOnlyCollection()return only new items after clear and partial refill.git diff --checkpassed.Full benchmark results and setup
Widecontains eightlongfields (64 bytes), compares all fields, and hashes the first.RefValuecontains alongand an object reference. Input values are created once and reused.Benchmark baseline
8ac60f59b95, with this PR's collection implementation applied for the patched runs. OnlySystem.Linq.Expressions.dlldiffers between the baseline and patched runtime images. Native runtime files are identical.Baseline/patched order was randomized with seed 136605. No outliers were removed. Clear-only uses one invocation per measurement and checks that all collections are empty afterward.
CycleBench<T>.ClearAndRefillclears and refills one collection per invocation. Refill is timed; existing storage and input values are reused. Each case recorded at least 10 seconds of measured work. Cleanup checks the final count.RemoveBench<T>.RemoveLastAndRefillremoves every item from the end, then refills the collection. Both steps are timed. Removal cases recorded 9.53 to 20.98 seconds of measured work per case in each process.Removal results, in microseconds per complete remove-and-refill cycle:
intintWideWideRefValueRefValueintintWideWideRefValueRefValueClear-only batches of sixteen collections, in microseconds.
intintWideWideRefValueRefValueintintWideWideRefValueRefValueSustained clear-and-refill cycles, in microseconds.
intintWideWideRefValueRefValueintintWideWideRefValueRefValueHigher patched means in at least one process:
RefValueat 1,024 items (Clear-only, up to 85.4%),RefValueat 65,536 items (Clear-only, up to 30.3%),intat 1,024 items (clear-and-refill, up to 2.1%),RefValueat 1,024 items (clear-and-refill, up to 1.3%),RefValueat 65,536 items (clear-and-refill, up to 5.3%),intat 1,024 items (remove-last-and-refill, up to 30.2%),intat 65,536 items (remove-last-and-refill, up to 12.3%).Timed methods
Note
The implementation, tests, and pull request description were prepared with OpenAI Codex (Fable). I used Tedd.DotNetLab for the performance investigation. I have manually reviewed and checked everything.