# Case Study: Method Invalidations caused by Pkg.jl with Julia 1.11

**URL:** https://discourse.julialang.org/t/case-study-method-invalidations-caused-by-pkg-jl-with-julia-1-11/109038
**Category:** Internals & Design
**Tags:** method-invalidation
**Created:** [January 20, 2024, 6:55am UTC](https://discourse.julialang.org/t/case-study-method-invalidations-caused-by-pkg-jl-with-julia-1-11/109038 "2024-01-20T06:55:23Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![jakobnissen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jakobnissen/32/13477_2.png) [@jakobnissen](https://discourse.julialang.org/u/jakobnissen)
#### Post date: [January 20, 2024, 9:14am UTC](https://discourse.julialang.org/t/case-study-method-invalidations-caused-by-pkg-jl-with-julia-1-11/109038/2 "2024-01-20T09:14:43Z")

</div>

One could also consider a deeper root cause to be the combination of:

1. People don’t write type-stable code consistently. If the authors of Pkg - presumably seasoned Julia core devs - doesn’t create type-stable code, it’s hard to have hope that the broader ecosystem will be type-stable
2. Type unstable code is prone to invalidations from third-party code. This is due to compiler optimisations that try to regain performance from some type-unstable code

I fear the only reasonable solution to this problem is to remove the compiler optimisations mentioned in 2. If we don’t, we’re going to play invalidation whack-a-mole until the end of time, while also living with the fact that invalidations will continue to be rampant in the wider ecosystem - see e.g. [this post](https://discourse.julialang.org/t/how-to-help-reduce-package-load-latency/105294/1) where a single package causes 66,000 invalidations.

Also, having the optimisations in 2. defeats the idea that Julia devs can strategically choose to write type-unstable code where performance is not important. This is not actually a possibility if type instability across any larger piece of code causes uncontrollable invalidation and latency, even for code that is not performance sensitive.

---

_[View the full topic](https://discourse.julialang.org/t/case-study-method-invalidations-caused-by-pkg-jl-with-julia-1-11/109038)._
