Reduce allocations when materializing MAP values#342
Draft
skuirrels wants to merge 1 commit into
Draft
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #342 +/- ##
========================================
Coverage 87.59% 87.59%
========================================
Files 77 77
Lines 3143 3176 +33
Branches 466 476 +10
========================================
+ Hits 2753 2782 +29
- Misses 276 277 +1
- Partials 114 117 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
What changed
MAP values currently go through
IDictionary, which boxes numeric keys and values and letsDictionarygrow as entries are added.This keeps that fallback for custom or wider dictionary targets, but adds a typed path for normal
Dictionary<TKey, TValue>reads:Nullable values, provider-specific types, nested values, and derived/wider dictionaries keep the existing behavior.
Benchmark
The benchmark materializes 100,000 rows of
Dictionary<int, int>, with 16 entries per row:Results are the median of 7 measured runs after warmup, using a Release build on the same machine.
The allocation reduction is the useful result here. The elapsed-time difference is small enough to treat as noise.
Validation
git diff --checkpasses