-
Notifications
You must be signed in to change notification settings - Fork 4k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Defer array creation in ConcurrentCache. #72291
Conversation
// short-lived compilations that do not end up using the cache. As the cache is simple best-effort, it's | ||
// fine if multiple threads end up creating the backing array at the same time. One thread will be last and | ||
// will win, and the others will just end up creating a small piece of garbage that will be collected. | ||
: base(size, createBackingArray: false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i kept this logic only for ConcurrentCache, as it's this cache that says explicitly: expiration policy is "new entry wins over old entry if hashed into the same bucket"
. So it felt safest to have just for this type. We could move this down to the base if we're ok with this policy for all subclsses.
Speedometer/DDRITs shows no regressions. @dotnet/roslyn-compiler for review here. Thanks! |
} | ||
|
||
public bool TryGetValue(TKey key, [MaybeNullWhen(returnValue: false)] out TValue value) | ||
{ | ||
int hash = RuntimeHelpers.GetHashCode(key); | ||
int idx = hash & mask; | ||
|
||
var entries = this.entries; | ||
var entries = this.Entries; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair. but this keeps things exactly the same otherwise. something we could consider.
@dotnet/roslyn-compiler ptal |
@333fred ptal. |
Followup to #72290.
I want to also run this through speedometer to ensure it helps out.
--
Build: https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_build/results?buildId=9159598&view=results
https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_build/results?buildId=9160401&view=results