# \[ANN\] PrecompileSignatures.jl: Generate precompile directives by reading method signatures

**URL:** <https://discourse.julialang.org/t/ann-precompilesignatures-jl-generate-precompile-directives-by-reading-method-signatures/80943>\
**Category:** Package Announcements\
**Tags:** announcement, performance, ttfx\
**Created:** [May 12, 2022, 9:30am UTC](https://discourse.julialang.org/t/ann-precompilesignatures-jl-generate-precompile-directives-by-reading-method-signatures/80943 "2022-05-12T09:30:16Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)\
**Post date:** [May 12, 2022, 9:30am UTC](https://discourse.julialang.org/t/ann-precompilesignatures-jl-generate-precompile-directives-by-reading-method-signatures/80943/1 "2022-05-12T09:30:17Z")

</div>

[`PrecompileSignatures.jl`](https://github.com/rikhuijzer/PrecompileSignatures.jl) is a package which reduces TTFX by moving some just in time compilation to the precompilation phase. The package does this by reading all method signatures in a package and generating precompile directives for any concrete signature that it can find.

This idea of this package came when reducing the TTFX for [`Pluto.jl`](https://github.com/fonsp/Pluto.jl/). At one point we realized that adding **one** precompile directive reduced the TTFX for one of Pluto’s main methods by 3 seconds (see [Use `precompile` for `SessionActions.open` by rikhuijzer · Pull Request #1934 · fonsp/Pluto.jl · GitHub](https://github.com/fonsp/Pluto.jl/pull/1934) for details). Once we realized that, we started to manually add `precompile` directives. This worked quite well, but is hard to maintain. With PrecompileSignatures.jl, adding the directives is now automated.

How much this package can reduce the TTFX depends on the package. The more signatures a package has with concretely typed arguments, the more `precompile` directives can be added. Next, the better the types inside the methods can be infered, the more performance can be gained from adding the directives. This last point depends a lot on Julia’s compiler. Newer Julia versions have a better compiler and better caching which make `precompile` more effective.

In general, I expect that the packages which are applications such as Pluto.jl or [`Genie.jl`](https://github.com/GenieFramework/Genie.jl) _or_ where methods cannot be easily executed during precompilation due to side-effects will benefit the most from PrecompileSignatures.jl. Note that the `precompile` directives are **generated during the precompilation phase** , so there is no need to store separate `src/precompile.jl` files in your repository.

For more info, see the [`README`](https://github.com/rikhuijzer/PrecompileSignatures.jl).

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [May 12, 2022, 11:49am UTC](https://discourse.julialang.org/t/ann-precompilesignatures-jl-generate-precompile-directives-by-reading-method-signatures/80943/2 "2022-05-12T11:49:52Z")

</div>

Just one thing, if I understood well the README the precompilation works for methods whose arguments have been annotated with their type and these are concrete… this isn’t however in contrast to trying to keep the function signatures the more general as possible in order to facilitate code composability ?

---

<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 12, 2022, 12:33pm UTC](https://discourse.julialang.org/t/ann-precompilesignatures-jl-generate-precompile-directives-by-reading-method-signatures/80943/3 "2022-05-12T12:33:47Z")

</div>

As I recall it used to be possible to generate precompile statements from the package’s tests using [SnoopCompile.jl](https://timholy.github.io/SnoopCompile.jl/stable/)  
I am pretty sure it still is.  
But IIRC it is no longer highlighted as a main use case as there was a reason to avoid adding huge numbers of precompile statements without some thought.  
Though I can’t remember what it was. @tim.holy ?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [May 12, 2022, 12:56pm UTC](https://discourse.julialang.org/t/ann-precompilesignatures-jl-generate-precompile-directives-by-reading-method-signatures/80943/4 "2022-05-12T12:56:30Z")

</div>

> [@oxinabox](#):
>
> But IIRC it is no longer highlighted as a main use case as there was a reason to avoid adding huge numbers of precompile statements without some thought.  
> Though I can’t remember what it was. @tim.holy ?

It is easier to just have a small representative workload that runs during precompile time. That will always be updated, even if function names etc change in the package.

---

<div class="post-metadata">

**Author:** ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)\
**Post date:** [May 12, 2022, 1:36pm UTC](https://discourse.julialang.org/t/ann-precompilesignatures-jl-generate-precompile-directives-by-reading-method-signatures/80943/5 "2022-05-12T13:36:27Z")

</div>

Depends on the package. For a package like Pluto there is almost zero need to keep things generic. Especially at the more high-level functions.

---

<div class="post-metadata">

**Author:** ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)\
**Post date:** [May 12, 2022, 1:41pm UTC](https://discourse.julialang.org/t/ann-precompilesignatures-jl-generate-precompile-directives-by-reading-method-signatures/80943/6 "2022-05-12T13:41:47Z")

</div>

Agreed. Or PrecompileSignatures which generates the precompile directives during the precompilation phase. The drawback of a workload is that it can also become outdated and can be problematic when there are side-effects.

PackageCompile, SnoopCompile, workload and PrecompileSignatures all have their drawbacks and benefits IMO.

---

<div class="post-metadata">

**Author:** ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)\
**Post date:** [May 13, 2022, 5:35pm UTC](https://discourse.julialang.org/t/ann-precompilesignatures-jl-generate-precompile-directives-by-reading-method-signatures/80943/7 "2022-05-13T17:35:50Z")

</div>

I’m also working on automatically converting some abstract types to concrete. It currently automatically converts `AbstractString` to `String` before generating precompile directives. Often, methods precompiled for some subtype of an abstract type are also quicker for other subtypes, so that is why doing this is useful.

I’m still working on making this API public to pass the types and experiment with it. For example, for a package like Distributions, we could precompile all `Real`s as `Float64` since floats are passed into the methods 90% of the time.

---

<div class="post-metadata">

**Author:** ![ConnectedSystems](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/connectedsystems/32/16815_2.png) [@ConnectedSystems](https://discourse.julialang.org/u/ConnectedSystems)\
**Post date:** [December 26, 2025, 9:59pm UTC](https://discourse.julialang.org/t/ann-precompilesignatures-jl-generate-precompile-directives-by-reading-method-signatures/80943/8 "2025-12-26T21:59:58Z")

</div>

Sorry for reviving an old thread but I see the last official release was three years ago.

Is PrecompileSignatures now mature enough that no additional work is being planned, has it been superceded by other efforts, or is it simply dormant?

---

<div class="post-metadata">

**Author:** ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)\
**Post date:** [December 29, 2025, 8:30am UTC](https://discourse.julialang.org/t/ann-precompilesignatures-jl-generate-precompile-directives-by-reading-method-signatures/80943/9 "2025-12-29T08:30:23Z")

</div>

I think [GitHub - JuliaLang/PrecompileTools.jl: Reduce time-to-first-execution of Julia code](https://github.com/JuliaLang/PrecompileTools.jl) is the way to go nowadays

---

<div class="post-metadata">

**Author:** ![ConnectedSystems](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/connectedsystems/32/16815_2.png) [@ConnectedSystems](https://discourse.julialang.org/u/ConnectedSystems)\
**Post date:** [December 29, 2025, 8:32am UTC](https://discourse.julialang.org/t/ann-precompilesignatures-jl-generate-precompile-directives-by-reading-method-signatures/80943/10 "2025-12-29T08:32:54Z")

</div>

Thanks for the response.

It’s a shame because I liked the intermediate approach it provided, where I could simply:

`@precompile_signatures(module_name)`

and be on my way…

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [December 29, 2025, 10:24am UTC](https://discourse.julialang.org/t/ann-precompilesignatures-jl-generate-precompile-directives-by-reading-method-signatures/80943/11 "2025-12-29T10:24:41Z")

</div>

You can still use this. As the original post and links suggest, an actively updated Pluto.jl still uses PrecompileSignatures.jl (just check the Project.toml files), so there’s a strong incentive for the latter to keep working despite the lack of recent developments.

> [@ConnectedSystems](#):
>
> has it been superceded by other efforts

It was never superseded, it was always a rarer approach for less generic packages with concretely typed methods that wouldn’t explode in number. Precompilation has changed a bit in the last 3 years, but that aspect hasn’t.

---

<div class="post-metadata">

**Author:** ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)\
**Post date:** [December 29, 2025, 1:32pm UTC](https://discourse.julialang.org/t/ann-precompilesignatures-jl-generate-precompile-directives-by-reading-method-signatures/80943/12 "2025-12-29T13:32:43Z")

</div>

Thanks @Benny

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [December 29, 2025, 9:50pm UTC](https://discourse.julialang.org/t/ann-precompilesignatures-jl-generate-precompile-directives-by-reading-method-signatures/80943/13 "2025-12-29T21:50:47Z")

</div>

How about [Speculator.jl: Reduce latency through speculative compilation](https://discourse.julialang.org/t/speculator-jl-reduce-latency-through-speculative-compilation/124344) ?

---

<div class="post-metadata">

**Author:** ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)\
**Post date:** [December 30, 2025, 3:53pm UTC](https://discourse.julialang.org/t/ann-precompilesignatures-jl-generate-precompile-directives-by-reading-method-signatures/80943/14 "2025-12-30T15:53:50Z")

</div>

For anyone now confused about what method to use: try everything that seems useful and run benchmarks. Only benchmarks will tell you what works and what doesn’t work.

---

<div class="post-metadata">

**Author:** ![ConnectedSystems](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/connectedsystems/32/16815_2.png) [@ConnectedSystems](https://discourse.julialang.org/u/ConnectedSystems)\
**Post date:** [January 1, 2026, 12:43pm UTC](https://discourse.julialang.org/t/ann-precompilesignatures-jl-generate-precompile-directives-by-reading-method-signatures/80943/15 "2026-01-01T12:43:23Z")

</div>

Yeah, I saw the announcement, which led me to go back and check what I was trying previously, which led me to asking the question above.

It’s awesome work and I’m grateful for all the effort the community puts in, but opens the question of what to use, what the differences are, and when all of this is will become handled auto-magically and I as a user can stop worrying about it 😜
