Skip to content

Feature request: Automatically precompile concrete method signatures #46634

Open

Description

I noticed that Julia does not automatically precompile methods where the signature is composed of only concrete types. This seems like a low-hanging fruit to improve precompilation somewhat. Presumably any method with a concrete signature can be expected to be called.

I tested a few of my own packages and found that around 1/4 - 1/6 of all methods were concrete. This was with a naive analysis which does not catch e.g. foo(x:T) where {T <: Int} as being concrete.

To test the potential impact, I went into a larger package of mine with noticable latency, and extracted all concrete signatures, then created precompile statements for these. The latency of the package dropped from 9.89 seconds to 9.26 seconds (repeated measures confirms this is preproducible).

Pluto.jl uses a similar approach with similar small, but positive results. See also the discussion in issue #12897.

Note that neither concrete methods in dependencies were precompiled, nor methods with abstract signatures that could be inferred to be called from concrete methods. Hence, the improvement if Base Julia did this would be even higher.

While this is only a minor improvement, it's a simple thing to do, and the difference could be even more impactful if native code caching happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions