Skip to content
This repository was 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
jkotas merged 2 commits into
dotnet:masterfrom
filipnavara:stackcrawl2
Jan 4, 2019
Merged

Avoid passing stack crawl mark unnecessarily deep in the call stack.#21783
jkotas merged 2 commits into
dotnet:masterfrom
filipnavara:stackcrawl2

Conversation

@filipnavara

@filipnavara filipnavara commented Jan 3, 2019

Copy link
Copy Markdown
Member

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

jkotas commented Jan 3, 2019

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
Member Author

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

@filipnavara

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

jkotas commented Jan 4, 2019

Copy link
Copy Markdown
Member

@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 jkotas left a comment

Copy link
Copy Markdown
Member

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

Development

Successfully merging this pull request may close these issues.

2 participants