# How to tell if invalidations are worth fixing?

**URL:** <https://discourse.julialang.org/t/how-to-tell-if-invalidations-are-worth-fixing/61950>\
**Category:** General Usage\
**Created:** [May 27, 2021, 5:34pm UTC](https://discourse.julialang.org/t/how-to-tell-if-invalidations-are-worth-fixing/61950 "2021-05-27T17:34:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Post date:** [May 27, 2021, 5:34pm UTC](https://discourse.julialang.org/t/how-to-tell-if-invalidations-are-worth-fixing/61950/1 "2021-05-27T17:34:17Z")

</div>

I can use [SnoopCompile](https://github.com/timholy/SnoopCompile.jl) to detect invalidations.  
and the manual talks about how to fix them by modifying the code that gets invalidated.  
But it is also possible to fix it sometimes by modifying the code that causes the invalidation.  
Namely, you can delete it.  
Normally don’t want to do this, but if it is an obscure and largely unused overload in a highly used package I guess it can be worth it.

To determine if it is worth it, I want to know how much removing it would speed “things” up.  
But I don’t exactly know what things I should measure.

Example is that convert in ChainRulesCore causes 126 invalidations.  
[https://github.com/JuliaDiff/ChainRulesCore.jl/issues/359](https://github.com/JuliaDiff/ChainRulesCore.jl/issues/359)  
We absolutely could remove that (and might have other reasons to beyond invalidations) but I don’t know if removing it would save 1 millisecond per user per year, or 10ms per user per day.

What should i measure before and after the change of removing it?

---

<div class="post-metadata">

**Author:** ![tecosaur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tecosaur/32/23206_2.png) [@tecosaur](https://discourse.julialang.org/u/tecosaur)\
**Post date:** [June 12, 2024, 8:52am UTC](https://discourse.julialang.org/t/how-to-tell-if-invalidations-are-worth-fixing/61950/3 "2024-06-12T08:52:54Z")

</div>

Sounds like you want [add `--trace-compile-timing` arg to add compile timing comments by IanButterworth · Pull Request #54662 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/54662) 🙂

---

<div class="post-metadata">

**Author:** ![tecosaur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tecosaur/32/23206_2.png) [@tecosaur](https://discourse.julialang.org/u/tecosaur)\
**Post date:** [June 12, 2024, 9:01am UTC](https://discourse.julialang.org/t/how-to-tell-if-invalidations-are-worth-fixing/61950/4 "2024-06-12T09:01:23Z")

</div>

Ooops, this is a necro. Discourse showed it to me on the front page and I just assumed it was recent 😅

---

<div class="post-metadata">

**Author:** ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)\
**Post date:** [June 12, 2024, 9:16am UTC](https://discourse.julialang.org/t/how-to-tell-if-invalidations-are-worth-fixing/61950/5 "2024-06-12T09:16:53Z")

</div>

> [@tecosaur](#):
>
> Discourse showed it to me on the front page and I just assumed it was recent 😅

It did also show up on top of the front for this morning (before you posted), so you are not alone. Is that an intentional feature of discourse? 🤔

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [June 12, 2024, 9:39am UTC](https://discourse.julialang.org/t/how-to-tell-if-invalidations-are-worth-fixing/61950/6 "2024-06-12T09:39:44Z")

</div>

I believe it had a nonsense comment earlier today, which might have been flagged and removed. Possibly it was still on the front page during the removal process.
