Skip to content

Conversation

@h3xds1nz
Copy link
Member

@h3xds1nz h3xds1nz commented Jan 7, 2025

Description

Replaces boxing Hashtable with an instance of ReadOnlyDictionary<K, V>, cutting allocation in half and increasing throughput around 3 times on the static ctor that is gonna get initialized in pretty much every Wpf application with controls.

The query times will be of course improved as well due to non-boxing key query.

Sample ctor improvement

Method Mean [ns] Error [ns] StdDev [ns] Gen0 Code Size [B] Gen1 Allocated [B]
Original 1,446.8 ns 25.41 ns 27.18 ns 0.5684 4,095 B 0.0076 9528 B
PR__EDIT 476.9 ns 8.28 ns 7.34 ns 0.2737 2,716 B 0.0019 4584 B

Customer Impact

Improved performance, decreased allocations.

Regression

No.

Testing

Local build.

Risk

Low, it's a simple type-swap with static initialization.

Microsoft Reviewers: Open in CodeFlow
@h3xds1nz h3xds1nz requested review from a team as code owners January 7, 2025 22:25
@dotnet-policy-service dotnet-policy-service bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage

1 participant