Repository navigation
perf: counting discarded telemetry for client reports no longer allocates - #5687
Merged
Merged
Conversation
…ates ThreadsafeCounterDictionary.Add and Increment passed a new CounterItem to GetOrAdd, allocating 24 B on every call even when the counter already existed. Use the factory overload so the item is only created for a new key. Closes #5686 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5687 +/- ##
==========================================
- Coverage 75.21% 75.13% -0.08%
==========================================
Files 515 515
Lines 18989 18989
Branches 3693 3695 +2
==========================================
- Hits 14282 14267 -15
- Misses 3852 3867 +15
Partials 855 855 ☔ 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.
ThreadsafeCounterDictionary.AddandIncrementpassednew CounterItem()toConcurrentDictionary.GetOrAdd, so every recorded discard allocated aCounterItem(24 B), even when the counter already existed. #5607 put these calls on hot paths, such as every dropped log or metric. The factory overload only creates the item for a new key.The new test measures allocations with
GC.GetAllocatedBytesForCurrentThread, so it only runs on .NET (not .NET Framework or mobile). It fails onmainwith 48 B, 24 B for each of its two calls.Closes #5686
Part of #5634
🤖 Generated with Claude Code