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

optimize invokelatest #38835

Merged
merged 1 commit into from
Dec 14, 2020
Merged

optimize invokelatest #38835

merged 1 commit into from
Dec 14, 2020

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Dec 11, 2020

People previously were making dumb work-arounds like try/catch around this to get a bit faster here (which is slightly slower than a generic dispatch currently, so that "optimization" may actually directly reduce their performance), since the compiler couldn't optimize it before at all. Applications typically shouldn't use this function in performance sensitive places, as it hints that their design is flawed, but might as well make it faster anyways. There's not a lot of headroom for better performance, so I am skeptical of their performance analysis though.

julia> g() = nothing
g (generic function with 1 method)

julia> f() = Base.invokelatest(g)
f (generic function with 1 method)

julia> @btime f() # master
  36.794 ns (0 allocations: 0 bytes)

julia> @btime f() # This PR
  14.401 ns (0 allocations: 0 bytes)

julia> @btime $(Any[g])[]() # for reference, confirming that there's almost no overhead now
  13.003 ns (0 allocations: 0 bytes)

@vtjnash vtjnash force-pushed the jn/invokelatest-faster branch from 3ccf6aa to 516fe7c Compare December 11, 2020 16:30
@vtjnash vtjnash force-pushed the jn/invokelatest-faster branch from 516fe7c to 3870a65 Compare December 11, 2020 17:06
People previously were making dumb work-arounds like try/catch around
this to get a bit faster here, since the compiler couldn't optimize it
before. Applications typically shouldn't use this function in
performance sensitive places, as it hints that their design is flawed,
but might as well make it faster anyways.

and optimize invokelatest kwcall too, while we are at it
@vtjnash vtjnash force-pushed the jn/invokelatest-faster branch from 3870a65 to 8b7f947 Compare December 11, 2020 19:40
@JeffBezanson JeffBezanson merged commit 2ff110b into master Dec 14, 2020
@JeffBezanson JeffBezanson deleted the jn/invokelatest-faster branch December 14, 2020 18:01
aviatesk added a commit to aviatesk/JuliaInterpreter.jl that referenced this pull request Dec 15, 2020
this essentially updates to 
JuliaLang/julia#38835, 
where `_apply_latest` is renamed to `_call_latest`
simeonschaub pushed a commit to simeonschaub/JuliaInterpreter.jl that referenced this pull request Dec 17, 2020
this essentially updates to 
JuliaLang/julia#38835, 
where `_apply_latest` is renamed to `_call_latest`
simeonschaub pushed a commit to simeonschaub/JuliaInterpreter.jl that referenced this pull request Dec 17, 2020
this essentially updates to
JuliaLang/julia#38835,
where `_apply_latest` is renamed to `_call_latest`
vtjnash added a commit that referenced this pull request Feb 16, 2021
Applications typically shouldn't use this function in
performance sensitive places, as it hints that their design is flawed,
but might as well make it faster anyways.

and optimize invokelatest kwcall too, while we are at it

(cherry picked from commit 2ff110b)
@KristofferC KristofferC added the backport 1.6 Change should be backported to release-1.6 label Feb 17, 2021
@KristofferC KristofferC removed the backport 1.6 Change should be backported to release-1.6 label Mar 14, 2021
ElOceanografo pushed a commit to ElOceanografo/julia that referenced this pull request May 4, 2021
Applications typically shouldn't use this function in
performance sensitive places, as it hints that their design is flawed,
but might as well make it faster anyways.

and optimize invokelatest kwcall too, while we are at it
staticfloat pushed a commit that referenced this pull request Dec 23, 2022
Applications typically shouldn't use this function in
performance sensitive places, as it hints that their design is flawed,
but might as well make it faster anyways.

and optimize invokelatest kwcall too, while we are at it

(cherry picked from commit 2ff110b)
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.

4 participants