Skip to content

Conversation

@rajbarik
Copy link

@rajbarik rajbarik commented May 15, 2023

Go launched Profile-Guided Optimization (PGO) with v1.20.
With this, inlining optimization now uses a threshold called inlineHotMaxBudget which has a default value of 2000 for PGO-based inlining [Line 76, inl.go]. This will enable more inling. However, inlining continues not to work if a function/method contains defer statements [Line 619, inl.go]

This PR eliminates many defer constructs in scope.go and scope_registry.go in order to enable more inlining. For example, smaller functions such as scope::counter(sanitizedName string) and scope::gauge(name string) should be inlined after removing defers in them.

I should also mention that I have gone to the extreme in removing many defers. We should vet all the changes keeping in mind panic behaviors and make sure they are correct before merging this PR.

@CLAassistant
Copy link

CLAassistant commented May 15, 2023

CLA assistant check
All committers have signed the CLA.

@rajbarik
Copy link
Author

@prateek FYI.

@rabbbit
Copy link

rabbbit commented May 16, 2023

Did you measure the expected efficiency wins from this in any way? In other words, is the extra brittleness worth it?

I was hoping that https://go-review.googlesource.com/c/go/+/479095 would have fixed this - but it looks like they only change the closure behavior, not defer.

Is a similar change to allow inlinfing functions with defers not possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants