# Invalidations findings (from a GMT case)

**URL:** https://discourse.julialang.org/t/invalidations-findings-from-a-gmt-case/92420
**Category:** General Usage
**Tags:** performance
**Created:** [January 2, 2023, 2:55pm UTC](https://discourse.julialang.org/t/invalidations-findings-from-a-gmt-case/92420 "2023-01-02T14:55:54Z")
**Posts on this page:** 1
**Showing post:** 32

<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 3, 2023, 6:02pm UTC](https://discourse.julialang.org/t/invalidations-findings-from-a-gmt-case/92420/32 "2023-01-03T18:02:17Z")

</div>

> Take for example the last one above, the [helper\_arrows](https://github.com/GenericMappingTools/GMT.jl/blob/master/src/plot.jl#L1007). It’s a simple internal function. Why is it invalidated?

Great question! If you look at the source of `helper_arrows`, you can see it calls `*`. For one or more of the calls `x * y` (the same as `*(x, y)`), the type of `x` and/or `y` must not be inferrable. Thus when you precompile GMT, `helper_arrows` gets compiled with a potential list of `*` methods that _might_ apply, but loading ChainRulesCore added a new `*` method that _also_ might apply. So it threw away all the old compiled code so that it could be recompiled to take this new possibility into account.

You can learn more like this:

```julia
julia> using GMT # thanks for making GMT easy to build!!!!

julia> code_warntype(GMT.helper_arrows, (Dict, Bool))

```

and look for red. Unfortunately it looks like the file & line numbers don’t work for `code_warntype`, but you can use `code_typed(GMT.helper_arrows, (Dict, Bool); debuginfo=:source, optimize=false)` and track down those statements that correspond to the lines with red.

In your case, it looks like your call to `string(::Real)` is inferred as `::Any`; if you put `::String` after that call, you might fix it. I.e., `"$val"::String` for your specific code.

FWIW, this type of analysis is better done with `ascend`, and highly recommended if you have a lot of invalidations to fix. But there’s a bit of a learning curve, so using `code_typed` is a good alternative.

---

_[View the full topic](https://discourse.julialang.org/t/invalidations-findings-from-a-gmt-case/92420)._
