# Julia v1.9.0-beta2 is fast

**URL:** <https://discourse.julialang.org/t/julia-v1-9-0-beta2-is-fast/92290>\
**Category:** Performance\
**Created:** [December 29, 2022, 8:48pm UTC](https://discourse.julialang.org/t/julia-v1-9-0-beta2-is-fast/92290 "2022-12-29T20:48:32Z")\
**Posts on this page:** 5\
**Page:** 3

<div class="post-metadata">

**Author:** ![heltonmc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heltonmc/32/43044_2.png) [@heltonmc](https://discourse.julialang.org/u/heltonmc)\
**Post date:** [January 5, 2023, 3:16pm UTC](https://discourse.julialang.org/t/julia-v1-9-0-beta2-is-fast/92290/41 "2023-01-05T15:16:23Z")

</div>

> [@DNF](#):
>
> What does `@eval` actually do here? Is it necessary?

In this case, for the second call measuring TTFX yes. I can’t remember where this discussion took place but looking at the docs is helpful [Essentials · The Julia Language](https://docs.julialang.org/en/v1/base/base/#Base.@time) for the time macro.

> In some cases the system will look inside the `@time` expression and compile some of the called code before execution of the top-level expression begins. When that happens, some compilation time will not be counted. To include this time you can run `@time @eval ...`.

… is the relevant section. So using just time in the second call doesn’t include some of the compile time.

```julia
julia> @time using Bessels
  0.022755 seconds (22.24 k allocations: 2.378 MiB)

# main difference
julia> @time besselj(1.2, 8.2)
  0.000004 seconds
0.21735942469289246

```

---

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [January 5, 2023, 3:23pm UTC](https://discourse.julialang.org/t/julia-v1-9-0-beta2-is-fast/92290/42 "2023-01-05T15:23:52Z")

</div>

```julia
julia> @macroexpand @time 1
quote
    #= timing.jl:263 =#
    begin
        #= timing.jl:268 =#
        $(Expr(:meta, :force_compile))

```

`@time` compiles the block it is in.  
Given that the block includes the expression you’re timing, that often means it can be compiled before timing.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [January 5, 2023, 9:11pm UTC](https://discourse.julialang.org/t/julia-v1-9-0-beta2-is-fast/92290/43 "2023-01-05T21:11:30Z")

</div>

That’s an amazing speed up!

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [January 5, 2023, 9:51pm UTC](https://discourse.julialang.org/t/julia-v1-9-0-beta2-is-fast/92290/44 "2023-01-05T21:51:01Z")

</div>

It’s pretty much the perfect example. There’s a bunch of code that was perfectly inferred and has no invalidation. All of the methods are concrete so there’s no reason at all to need to recompile anything.

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [January 5, 2023, 10:20pm UTC](https://discourse.julialang.org/t/julia-v1-9-0-beta2-is-fast/92290/45 "2023-01-05T22:20:59Z")

</div>

Yep. You might wonder if that might be possible only with fairly small examples that are “pure” functions. But we even got the same 100 ~~0~~ x-scale speedup for `ImageFiltering.imfilter`, which is a pretty complicated function (basically the entire 1500-line source file `src/imfilter.jl`, though not all dispatch chains touch every method in that file). [Use SnoopPrecompile for precompilation by timholy · Pull Request #255 · JuliaImages/ImageFiltering.jl · GitHub](https://github.com/JuliaImages/ImageFiltering.jl/pull/255). And there might be actual computation setting the floor of the benefit; `imfilter` does actually take execution time…

Of course, I’ve stamped out invalidations in much of “my” code base a long time ago, which is why you get such dramatic improvements when you can flip the switch on native compilation.

[Previous page](https://discourse.julialang.org/t/julia-v1-9-0-beta2-is-fast/92290.md?page=2)
