Navigation Menu

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: inlining budget excludes cross-package calls #22194

Closed
mdempsky opened this issue Oct 10, 2017 · 2 comments
Closed

cmd/compile: inlining budget excludes cross-package calls #22194

mdempsky opened this issue Oct 10, 2017 · 2 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.

Comments

@mdempsky
Copy link
Member

In the example below, p.G and q.H are identical, except that p.G is in the same package as p.F, yet cmd/compile decides that q.H is inlineable whereas p.G is not.

This is because cmd/compile currently only computes Inlcost for locally defined functions. Calls to functions in external packages are effectively treated as free.

$ go tool compile -m p.go
p.go:3:6: can inline F
p.go:13:3: inlining call to F

$ go tool compile -m q.go
q.go:5:6: can inline H
q.go:6:5: inlining call to p.F

$ cat p.go
package p

func F() {
    print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
}

func G() {
    F()
    print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
}

$ cat q.go
package q

import "./p"

func H() {
    p.F()
    print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
}
@mdempsky mdempsky added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 10, 2017
@ALTree
Copy link
Member

ALTree commented Oct 10, 2017

This is #19261, see josh comment: #19261 (comment)

@mdempsky
Copy link
Member Author

mdempsky commented Oct 10, 2017

@ALTree Indeed, thanks! Closing as duplicate.

@golang golang locked and limited conversation to collaborators Oct 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants