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

imprecise inference of underlying method called by kwfunc method causes unnecessary allocation #30352

Open
jrevels opened this issue Dec 11, 2018 · 0 comments
Labels
keyword arguments f(x; keyword=arguments) performance Must go faster

Comments

@jrevels
Copy link
Member

jrevels commented Dec 11, 2018

Feel free to close if this is a dupe, but I really like this because of how tiny the MWE is:

julia> versioninfo()
Julia Version 1.1.0-DEV.843
Commit a0bc8fdb75 (2018-12-08 18:35 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin17.5.0)
  CPU: Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)

julia> @noinline f(a, b; c::Bool=true, d::Float64=1.0) = a * b + c * d
f (generic function with 1 method)

julia> x, y = rand(2);

julia> f(x, y) # warmup
1.0256215120847518

julia> @allocated f(x, y) # sad allocation :(
64

julia> @code_typed f(x, y) # _1 is only inferred as Function, I'm assuming that makes codegen sad
CodeInfo(
1%1 = invoke Main.:(#f#3)(true::Bool, 1.0::Float64, _1::Function, _2::Float64, _3::Float64)::Float64
└──      return %1
) => Float64
@jrevels jrevels changed the title underlying method called by kwfunc method not precisely inferred if invocation can't be inlined imprecise inference of underlying method called by kwfunc method causes unnecessary allocation Dec 11, 2018
@jrevels jrevels added performance Must go faster keyword arguments f(x; keyword=arguments) labels Dec 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keyword arguments f(x; keyword=arguments) performance Must go faster
Projects
None yet
Development

No branches or pull requests

1 participant