Skip to content
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

cmd/compile/internal/inline: hairyVisitor doesn't properly account for conditionally-inlined PGO calls #59484

Open
prattmic opened this issue Apr 7, 2023 · 1 comment
Assignees
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@prattmic
Copy link
Member

prattmic commented Apr 7, 2023

In hairVisitor.doNode we give calls a cost of 57, unless the call is inlineable, in which case we use the cost of the callee, under the assumption that this call will get inlined.

"Inlineable" here more-or-less just means that fn.Inl != nil. In a non-PGO build, we only set fn.Inl if the function cost is < 80, making it inlineable ~anywhere.

In a PGO build, fn.Inl is set for any function involved in a hot callsite (e.g., a -> b), but we will only inline at the hot callsite. Any other callsite (e.g., c -> b) will not inline. This makes the assumption incorrect and means that the cold caller (c) will have an artificially inflated cost, potentially making it too expensive to inline.

I will send a CL to fix this.

cc @cherrymui @thanm @mdempsky

@prattmic prattmic added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 7, 2023
@prattmic prattmic self-assigned this Apr 7, 2023
@prattmic prattmic added this to the Go1.21 milestone Apr 7, 2023
@gopherbot
Copy link

Change https://go.dev/cl/483196 mentions this issue: cmd/compile: synchronize inlinability logic between hairyVisitor and mkinlcall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
Status: In Progress
Development

No branches or pull requests

2 participants