# Forcing @inline

**URL:** <https://discourse.julialang.org/t/forcing-inline/20225>\
**Category:** Performance\
**Created:** [January 29, 2019, 10:17am UTC](https://discourse.julialang.org/t/forcing-inline/20225 "2019-01-29T10:17:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rgankema](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rgankema/32/6670_2.png) [@rgankema](https://discourse.julialang.org/u/rgankema)\
**Post date:** [January 29, 2019, 10:17am UTC](https://discourse.julialang.org/t/forcing-inline/20225/1 "2019-01-29T10:17:52Z")

</div>

I’ve got a relatively large function, that I’d like to be inlined. Although I used the `@inline` annotation, the compiler apparently still decides that it’s not worth inlining. It might be right, but I really want to at least measure whether that’s indeed true. Is there any way to force inlining?

---

<div class="post-metadata">

**Author:** ![bennedich](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bennedich/32/4894_2.png) [@bennedich](https://discourse.julialang.org/u/bennedich)\
**Post date:** [January 29, 2019, 10:30am UTC](https://discourse.julialang.org/t/forcing-inline/20225/2 "2019-01-29T10:30:41Z")

</div>

I guess you could make it a macro, or just copy and paste it into where it’s called.

---

<div class="post-metadata">

**Author:** ![maleadt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maleadt/32/10097_2.png) [@maleadt](https://discourse.julialang.org/u/maleadt)\
**Post date:** [January 29, 2019, 10:36am UTC](https://discourse.julialang.org/t/forcing-inline/20225/3 "2019-01-29T10:36:48Z")

</div>

Not since [https://github.com/JuliaLang/julia/pull/27857](https://github.com/JuliaLang/julia/pull/27857). But if you can make your dispatch signature concrete, you should hit [https://github.com/JuliaLang/julia/pull/29258](https://github.com/JuliaLang/julia/pull/29258)

---

<div class="post-metadata">

**Author:** ![traktofon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/traktofon/32/591_2.png) [@traktofon](https://discourse.julialang.org/u/traktofon)\
**Post date:** [January 29, 2019, 12:38pm UTC](https://discourse.julialang.org/t/forcing-inline/20225/4 "2019-01-29T12:38:47Z")

</div>

Could you elaborate what a “concrete dispatch signature” or (from the comment linked from your link) a “maximally typed function type” is? Thanks!

---

<div class="post-metadata">

**Author:** ![maleadt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maleadt/32/10097_2.png) [@maleadt](https://discourse.julialang.org/u/maleadt)\
**Post date:** [January 29, 2019, 2:05pm UTC](https://discourse.julialang.org/t/forcing-inline/20225/5 "2019-01-29T14:05:15Z")

</div>

> [@traktofon](#):
>
> Could you elaborate what a “concrete dispatch signature” or (from the comment linked from your link) a “maximally typed function type” is? Thanks!

There’s a reflection function:

```julia
help?> isdispatchtuple

  isdispatchtuple(T)

  Determine whether type T is a tuple "leaf type", meaning it could appear as a type signature in dispatch and has no subtypes (or supertypes) which could appear in a call

julia> isdispatchtuple(Tuple{Int})
true

julia> isdispatchtuple(Tuple{Any})
false

```

The latter occurs when the call to your function is badly typed:

```julia
julia> foo(x) = x
julia> bar(x) = foo(first(x))

julia> code_warntype(bar, Tuple{Vector{Int}})
Body::Int64
1 1 ─ ...
  │ %5 = invoke Main.foo(%4::Int64)::Int64
  └── return %5

julia> code_warntype(bar, Tuple{Vector{Any}})
Body::Any
1 1 ─ ...
  │ %5 = (Main.foo)(%4::Any)::Any
  └── return %5

```

In that case, doing dynamic dispatch will compile a specialized version for the concrete run-time types which is typically faster (ie. the function barrier pattern).
