-
Notifications
You must be signed in to change notification settings - Fork 451
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Performance: Optimize MetricsEventManager.QueuedEvents
Part of #7908. This is a contention hot path under load for 2 reasons: allocations on each key access (start and end of each event) and the `Monitor.Wait()` around the update portion of `.AddOrUpdate()`. There's also a string replication which isn't used on the `Data` string itself, but that's upstream and will pitch it in another PR. This change overall: optimizes the key access using a `readonly record struct` (for fast hashing), `Lazy<T>` (so we don't lose initial metrics), and moves the update outside of the dictionary path since each of the attributes on a metric are atomicly viable. Note though, this breaks StyleCop sporadically - before this can go in we'd need to update StyleCop and pull in DotNetAnalyzers/StyleCopAnalyzers#3401 which will be in the next 1.2.x beta. I've pinged Sam about getting a release there we can use.
- Loading branch information
1 parent
4a2b480
commit 03e9fb2
Showing
1 changed file
with
22 additions
and
33 deletions.
There are no files selected for viewing
This file contains 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