-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Avoid dictionary lookup for singleton services #52035
Conversation
- Stash the instance on the callsite itself and avoid the resolved services lookup.
Tagging subscribers to this area: @eerhardt, @maryamariyan Issue Details
|
- Don't lock if the callsite value is already resolved - Make the value on ServiceCallsite volatile
- cache callsites - update tests
/azp list |
/azp run runtime |
/azp run runtime-staging |
Azure Pipelines successfully started running 1 pipeline(s). |
1 similar comment
Azure Pipelines successfully started running 1 pipeline(s). |
src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceLookup/ServiceCallSite.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceLookup/CallSiteFactory.cs
Outdated
Show resolved
Hide resolved
LGTM, good change. |
src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceLookup/ServiceCacheKey.cs
Outdated
Show resolved
Hide resolved
...raries/Microsoft.Extensions.DependencyInjection/src/ServiceLookup/CallSiteRuntimeResolver.cs
Outdated
Show resolved
Hide resolved
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.
...raries/Microsoft.Extensions.DependencyInjection/src/ServiceLookup/CallSiteRuntimeResolver.cs
Show resolved
Hide resolved
@@ -5,7 +5,7 @@ | |||
|
|||
namespace Microsoft.Extensions.DependencyInjection.ServiceLookup | |||
{ | |||
internal struct ServiceCacheKey: IEquatable<ServiceCacheKey> | |||
internal readonly struct ServiceCacheKey : IEquatable<ServiceCacheKey> |
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.
Not directly related to your changes, but the HashCode calculation will throw for the static Empty
, the Type is null then, and GetHashCode will throw a null ref exception.
I suggest changing it to HashCode.Combine(Type, Slot)
which takes care of the null
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.
Will do that in a different PR.
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 created #52115 to fix that nullref exception.
@dotnet/dnceng can you please investigate what happened to Android legs?
I will rerun them |
@danmoseley based on the error message, this looks related to the issue we noticed yesterday: https://github.com/dotnet/core-eng/issues/12969 |
Thanks @missymessa . I also notice that there were test failures (https://dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_apis/build/builds/1115588/logs/91) but none of them were reported here. Is that related too? |
Looks like the test failures are showing up in AzDO. Are you meaning that they're not showing up on the Build Result Analysis? I think that's due to not having proper multi-pipeline support right now. |
What are these failures
@elinor-fung ? I can't see a relevant change in a quick look. |
@missymessa it's not clear now because I clicked rerun failed tests 😞 but I thought I wasn't seeing failed checkmarks on this PR page. Perhaps I've lost the repro state now. |
Thanks, @danmoseley. We shouldn't be running those on Mono - #52128 @LakshanF looks like we missed seeing the introduced test failures on mono+Windows in runtime-staging (test failures show up as passed checks on the PR) - something to make sure to check as the COM trimming work continues. |
GetService<A>
will only cache the A callsite. This change will result in caching A, B and C.PS: Still testing this.