Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Avoid passing stack crawl mark unnecessarily deep in the call stack. #21783

Merged
merged 2 commits into from Jan 4, 2019

Conversation

filipnavara
Copy link
Member

@filipnavara filipnavara commented Jan 3, 2019

TypeName::GetTypeWorker was passed both a stack mark and requesting assembly. Only the requesting assembly is actually needed and the stack mark can be resolved earlier if necessary.

@jkotas
Copy link
Member

jkotas commented Jan 3, 2019

Can this introduce (expensive) stackcrawl for caller assembly in some cases where it does not happen today? If yes, what are those cases and how important are they?

@filipnavara
Copy link
Member Author

Can this introduce (expensive) stackcrawl for caller assembly in some cases where it does not happen today?

As far as I can see it should not add any new stackcrawl that was not there before.

The code paths in TypeName::GetTypeWorker that didn't resolve the stack mark in the parameter can only occur if pRequestingAssembly != NULL || pAssemblyGetType != NULL. In every other case the stack mark was eventually resolved.

I moved up the stack mark resolution to TypeName::GetTypeManaged. GetTypeManaged always called GetTypeWorker with pRequestingAssembly: NULL. Thus we only need to consider the pAssemblyGetType != NULL code path.

There are three calls to TypeName::GetTypeManaged. Two of them don't pass in the stack mark, so there's nothing to resolve. The third one passes a stack mark, but it sets pAssemblyGetType: NULL. Thus even for the last one the stack mark resolution would always happen even before the change.

@filipnavara
Copy link
Member Author

@dotnet-bot test OSX10.12 x64 Checked Innerloop Build and Test

@filipnavara
Copy link
Member Author

On second thought I can move the resolution from TypeName::GetTypeManaged to RuntimeTypeHandle::GetTypeByName since it's the only call site that actually uses it.

@filipnavara filipnavara changed the title Avoid passing stack crawl mark unnecessarily deep in the call stack. WIP: Avoid passing stack crawl mark unnecessarily deep in the call stack. Jan 4, 2019
@filipnavara
Copy link
Member Author

Additionally, one stack crawl is saved if GetTypeManaged gets to the fallback case with period prefixes where GetTypeWorker is called twice. Admittedly that's not a common case, but it's an improvement nonetheless.

@filipnavara filipnavara changed the title WIP: Avoid passing stack crawl mark unnecessarily deep in the call stack. Avoid passing stack crawl mark unnecessarily deep in the call stack. Jan 4, 2019
@filipnavara
Copy link
Member Author

@dotnet-bot test Windows_NT x64 full_opt ryujit CoreCLR Perf Tests Correctness
@dotnet-bot test Windows_NT x64 min_opt ryujit CoreCLR Perf Tests Correctness
@dotnet-bot test Windows_NT x86 full_opt ryujit CoreCLR Perf Tests Correctness
@dotnet-bot test Windows_NT x86 min_opt ryujit CoreCLR Perf Tests Correctness

@jkotas
Copy link
Member

jkotas commented Jan 4, 2019

@dotnet-bot test Windows_NT x64 full_opt ryujit CoreCLR Perf Tests Correctness
@dotnet-bot test Windows_NT x64 min_opt ryujit CoreCLR Perf Tests Correctness
@dotnet-bot test Windows_NT x86 full_opt ryujit CoreCLR Perf Tests Correctness
@dotnet-bot test Windows_NT x86 min_opt ryujit CoreCLR Perf Tests Correctness

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Thanks

@jkotas jkotas merged commit 2ee2cb3 into dotnet:master Jan 4, 2019
@filipnavara filipnavara deleted the stackcrawl2 branch January 4, 2019 23:01
sandreenko pushed a commit to sandreenko/coreclr that referenced this pull request Jan 8, 2019
…otnet#21783)

* Avoid passing stack crawl mark unnecessarily deep in the call stack.

* Move stack crawl from TypeName::GetTypeManaged to RuntimeTypeHandle::GetTypeByName.
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…otnet/coreclr#21783)

* Avoid passing stack crawl mark unnecessarily deep in the call stack.

* Move stack crawl from TypeName::GetTypeManaged to RuntimeTypeHandle::GetTypeByName.


Commit migrated from dotnet/coreclr@2ee2cb3
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants