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

Inlining calls without concrete types can slow things down a lot #12219

Closed
simonster opened this issue Jul 19, 2015 · 4 comments
Closed

Inlining calls without concrete types can slow things down a lot #12219

simonster opened this issue Jul 19, 2015 · 4 comments
Labels
compiler:inference Type inference performance Must go faster

Comments

@simonster
Copy link
Member

In situations where a function is inlined without concrete type information, we can end up with multiple dynamic (jl_apply_generic) function calls when we only needed one before inlining, which can slow things down a lot. Consider:

g(x) = x + x + x + x + x + x + x + x

function h()
    x = Any[1][1]
    for i = 1:1000000
        g(x)
    end
end

julia> @time h()
 350.321 milliseconds (2000 k allocations: 62500 KB, 2.18% gc time)

After adding @noinline to g(x):

julia> @time h()
  17.324 milliseconds (5 allocations: 224 bytes)
@simonster simonster added performance Must go faster compiler:codegen Generation of LLVM IR and native code labels Jul 19, 2015
@simonster simonster changed the title Inlining function calls without concrete types can slow things down a lot Inlining calls without concrete types can slow things down a lot Jul 19, 2015
@yuyichao
Copy link
Contributor

Should be type inference not codegen?

@ArchRobison
Copy link
Contributor

ArchRobison commented Jun 10, 2016

Looks like I ran into this too.

It seems like jl_apply_generic should be split into two parts: one that does the lookup and one that does the call. Then the lookup portion could be subjected to CSE or PRE.

@KristofferC
Copy link
Member

FWIW, g doesn't get automatically inlined anymore.

@vtjnash
Copy link
Member

vtjnash commented Mar 12, 2020

Confirmed—nothing to do here anymore

@vtjnash vtjnash closed this as completed Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:inference Type inference performance Must go faster
Projects
None yet
Development

No branches or pull requests

5 participants