Skip to content

Fix rounding error in getLikelyClassesOrMethods - #86965

Merged
EgorBo merged 6 commits into
dotnet:mainfrom
EgorBo:fix-rounding-error-pgo
Jun 1, 2023
Merged

Fix rounding error in getLikelyClassesOrMethods#86965
EgorBo merged 6 commits into
dotnet:mainfrom
EgorBo:fix-rounding-error-pgo

Conversation

@EgorBo

@EgorBoEgorBo commented May 31, 2023

Copy link
Copy Markdown
Member

It seems that sometimes getLikelyClasses reports that fallback has e.g. 1% likelihood where in fact it's 0. It happens because of the rounding error accumulated in getLikelyClassesOrMethods. It prevents JIT from moving that fallback to a cold section.

@ghostghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label May 31, 2023
@ghostghost assigned EgorBoMay 31, 2023
@ghost

Copy link
Copy Markdown

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details

It seems that sometimes getLikelyClasses reports that fallback has e.g. 1% likelihood where in fact it's 0. It happens because of the rounding error accumulated in getLikelyClassesOrMethods. It prevents JIT from moving that fallback to a cold section.

publicstaticvoidMain(string[]args){for(inti=0;i<200;i++){Test(newMyClass1());Test(newMyClass1());Test(newMyClass1());Test(newMyClass2());Test(newMyClass3());Thread.Sleep(16);}}[MethodImpl(MethodImplOptions.NoInlining)]staticintTest(IValuevalue)=>value.GetValue();
- 1) 00007FFF3995A8C0 (MyClass1) [likelihood:50%]+ 1) 00007FFF3995A8C0 (MyClass1) [likelihood:51%]
2) 00007FFF3995AA88 (MyClass2) [likelihood:37%]
3) 00007FFF3995AC50 (MyClass3) [likelihood:12%]
Author:EgorBo
Assignees:EgorBo
Labels:

area-CodeGen-coreclr

Milestone:-

@EgorBo
EgorBo requested a review from AndyAyersMSMay 31, 2023 18:59
@EgorBoEgorBo mentioned this pull request May 31, 2023
14 tasks
Comment threadsrc/coreclr/jit/likelyclass.cpp
Comment threadsrc/coreclr/jit/likelyclass.cpp

@AndyAyersMSAndyAyersMS 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.

LGTM

@EgorBo
EgorBo merged commit d45a905 into dotnet:mainJun 1, 2023
@EgorBo
EgorBo deleted the fix-rounding-error-pgo branch June 1, 2023 09:57
@ghostghost locked as resolved and limited conversation to collaborators Jul 1, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@EgorBo@AndyAyersMS