# Potential performance regressions in Julia 1.8 for special un-precompiled type dispatches and how to fix them

**URL:** <https://discourse.julialang.org/t/potential-performance-regressions-in-julia-1-8-for-special-un-precompiled-type-dispatches-and-how-to-fix-them/86359>\
**Category:** Performance\
**Tags:** performance\
**Created:** [August 25, 2022, 8:27pm UTC](https://discourse.julialang.org/t/potential-performance-regressions-in-julia-1-8-for-special-un-precompiled-type-dispatches-and-how-to-fix-them/86359 "2022-08-25T20:27:47Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![charleskawczynski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/charleskawczynski/32/13783_2.png) [@charleskawczynski](https://discourse.julialang.org/u/charleskawczynski)\
**Post date:** [September 29, 2022, 7:22pm UTC](https://discourse.julialang.org/t/potential-performance-regressions-in-julia-1-8-for-special-un-precompiled-type-dispatches-and-how-to-fix-them/86359/22 "2022-09-29T19:22:14Z")

</div>

Regarding the output format for the invalidations reports, we’ve incorporated a relatively generic way of creating tables (e.g., below) that are similar to the plots made (e.g. [here](https://github.com/SciML/DifferentialEquations.jl/issues/786#issuecomment-1221515190)) but with more information (file / line number / method names) in [ReportMetrics.jl](https://github.com/CliMA/ReportMetrics.jl). The script looks like

```julia
using SnoopCompileCore
invalidations = @snoopr begin
    # load packages & do representative work
    nothing
end;
import ReportMetrics
ReportMetrics.report_invalidations(;
    job_name = "invalidations",
    invalidations,
    process_filename = x -> last(split(x, "packages/")),
)

```

And the output table looks like, for example:

```julia
┌─────────────────────────────────────────────────────┬───────────────────┬───────────────┬─────────────────┐
│ <file name>:<line number> │ Method Name │ Invalidations │ Invalidations % │
│ │ │ Number │ (xᵢ/∑x) │
├─────────────────────────────────────────────────────┼───────────────────┼───────────────┼─────────────────┤
│ ChainRulesCore/oBjCg/src/tangent_types/thunks.jl:29 │ ChainRulesCore.== │ 179 │ 63 │
│ ChainRulesCore/oBjCg/src/tangent_types/thunks.jl:28 │ ChainRulesCore.== │ 104 │ 36 │
│ ChainRulesCore/oBjCg/src/tangent_arithmetic.jl:105 │ ChainRulesCore.* │ 2 │ 1 │
└─────────────────────────────────────────────────────┴───────────────────┴───────────────┴─────────────────┘

```

Could this be somehow incorporated into the GitHub action for invalidations?

---

<div class="post-metadata">

**Author:** ![ranocha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ranocha/32/35588_2.png) [@ranocha](https://discourse.julialang.org/u/ranocha)\
**Post date:** [September 30, 2022, 11:48am UTC](https://discourse.julialang.org/t/potential-performance-regressions-in-julia-1-8-for-special-un-precompiled-type-dispatches-and-how-to-fix-them/86359/23 "2022-09-30T11:48:22Z")

</div>

That looks great! I think it would be very nice to incorporate it into the invalidations CI jobs.

---

<div class="post-metadata">

**Author:** ![charleskawczynski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/charleskawczynski/32/13783_2.png) [@charleskawczynski](https://discourse.julialang.org/u/charleskawczynski)\
**Post date:** [September 30, 2022, 7:18pm UTC](https://discourse.julialang.org/t/potential-performance-regressions-in-julia-1-8-for-special-un-precompiled-type-dispatches-and-how-to-fix-them/86359/24 "2022-09-30T19:18:30Z")

</div>

My only question is: where should the code be added? My first thought was to make [julia-invalidations](https://github.com/julia-actions/julia-invalidations) depend on ReportMetrics.jl, but that package also includes dependencies for reporting allocations. Alternatively, we could extract pieces from `report_invalidations` (my thought was to include everything except the code that needs PrettyTables) and add it to SnoopCompile. That might be nicer since it seems to be the lowest common denominator. I’ll open a PR and see what @tim.holy thinks 🙂

---

<div class="post-metadata">

**Author:** ![ranocha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ranocha/32/35588_2.png) [@ranocha](https://discourse.julialang.org/u/ranocha)\
**Post date:** [October 1, 2022, 7:31am UTC](https://discourse.julialang.org/t/potential-performance-regressions-in-julia-1-8-for-special-un-precompiled-type-dispatches-and-how-to-fix-them/86359/25 "2022-10-01T07:31:03Z")

</div>

Sounds good. Please let us know about the progress. I think it would be great to get a nice invalidation report in CI for many packages.

---

<div class="post-metadata">

**Author:** ![charleskawczynski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/charleskawczynski/32/13783_2.png) [@charleskawczynski](https://discourse.julialang.org/u/charleskawczynski)\
**Post date:** [October 1, 2022, 4:25pm UTC](https://discourse.julialang.org/t/potential-performance-regressions-in-julia-1-8-for-special-un-precompiled-type-dispatches-and-how-to-fix-them/86359/26 "2022-10-01T16:25:20Z")

</div>

Will do, so far I’ve opened [Add tabulated\_invalidations to tabulate inv summary by charleskawczynski · Pull Request #303 · timholy/SnoopCompile.jl · GitHub](https://github.com/timholy/SnoopCompile.jl/pull/303)

---

<div class="post-metadata">

**Author:** ![ranocha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ranocha/32/35588_2.png) [@ranocha](https://discourse.julialang.org/u/ranocha)\
**Post date:** [October 4, 2022, 4:02pm UTC](https://discourse.julialang.org/t/potential-performance-regressions-in-julia-1-8-for-special-un-precompiled-type-dispatches-and-how-to-fix-them/86359/27 "2022-10-04T16:02:53Z")

</div>

@sloede Do you have the bandwidth to re-run the benchmarks? There has been some significant work in Julia between versions 1.8.0 and 1.8.2. I used three Julia versions with the following code in a quick and dirty experiment:

```julia
julia -e 'import Pkg; Pkg.activate(temp=true); Pkg.add(["OrdinaryDiffEq", "Trixi"]); @time @eval(using OrdinaryDiffEq); @time @eval(using Trixi); @time trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_euler_taylor_green_vortex.jl"), maxiters=200)'

```

Then, I get the following timings (in seconds):

| | Julia 1.7.3 | Julia 1.8.0 | Julia 1.8.2 |
| --- | --- | --- | --- |
| `using OrdinaryDiffEq` | ca. 4.0 | ca. 6.5 | ca. 6.5 |
| `using Trixi` | ca. 14.5 | ca. 18.5 | ca. 16.5 |
| `trixi_include(...)` | ca. 50 | ca. 57 | ca. 43 |

If you can reproduce this trend by more scientific measurements (several repetitions etc.), this should indicate that we are on the right track.

[Previous page](https://discourse.julialang.org/t/potential-performance-regressions-in-julia-1-8-for-special-un-precompiled-type-dispatches-and-how-to-fix-them/86359.md?page=1)
