Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Reduce per-lookup overhead from key validation in HybridCache#6441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
MihaZupan merged 2 commits intodotnet:mainfromMihaZupan:key-validation
May 14, 2025

Conversation

@MihaZupan
Copy link
Member

@MihaZupanMihaZupan commentedMay 14, 2025
edited by dotnet-policy-servicebot
Loading

IndexOfAny(char[]) has per-call overhead to figure out what to do.
On modern .NET it would eventually hit a vectorized helper, but has to analyze the values every time.

Quick test with a defaultMemoryCache:

.NET 9/10

MethodJobKeyLengthMeanErrorRatio
GetCachedValuemain141.35 ns0.650 ns1.00
GetCachedValuepr141.71 ns0.824 ns1.01
GetCachedValuemain1659.67 ns1.192 ns1.00
GetCachedValuepr1641.36 ns0.852 ns0.69
GetCachedValuemain10070.41 ns1.420 ns1.00
GetCachedValuepr10053.16 ns1.043 ns0.76

Framework

MethodJobKeyLengthMeanErrorRatio
GetCachedValuemain1179.1 ns3.57 ns1.00
GetCachedValuepr1120.2 ns2.36 ns0.67
GetCachedValuemain16187.5 ns3.55 ns1.00
GetCachedValuepr16136.2 ns2.70 ns0.73
GetCachedValuemain100296.6 ns5.82 ns1.00
GetCachedValuepr100208.1 ns4.07 ns0.70
Microsoft Reviewers:Open in CodeFlow

Copy link
Contributor

@mgravellmgravell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nice tip!

@MihaZupanMihaZupan merged commit28d9967 intodotnet:mainMay 14, 2025
6 checks passed
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJun 14, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@stephentoubstephentoubstephentoub approved these changes

+1 more reviewer

@mgravellmgravellmgravell approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

@MihaZupanMihaZupan

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@MihaZupan@mgravell@stephentoub

[8]ページ先頭

©2009-2025 Movatter.jp