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

rikh
Thu, 12 May 2022 09:30:16 +0000
Package Announcements

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. 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 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 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.

15 posts - 7 participants