Skip to content

Run the precompile workload with PrecompileTools - #175

Open
aviatesk wants to merge 1 commit into
masterfrom
avi/use-precompile-tools
Open

aviatesk wants to merge 1 commit into
masterfrom
avi/use-precompile-tools

Conversation

@aviatesk

Copy link
Copy Markdown
Member

The precompile workload ran directly at the top level of src/packagedef.jl, guarded by jl_generating_output. Its variables, such as frame and edges, were left as globals of LoweredCodeUtils and saved in the package image. Code that the workload inferred for methods of other modules through runtime dispatch was not cached, since no backedge chain connects it to LoweredCodeUtils, and the workload could not be skipped.

This change moves the workload to src/precompile.jl and runs it with PrecompileTools. The workload lowers its input code in @setup_workload and calls the LoweredCodeUtils APIs in @compile_workload, which also caches the code inferred through runtime dispatch. Both blocks are let blocks so that their variables stay local, and users can skip the workload with the precompile_workload preference. As in JuliaInterpreter, src/precompile.jl is included from src/LoweredCodeUtils.jl, so src/packagedef.jl still loads without PrecompileTools.

The compat bound of PrecompileTools is 1.2.1, since PrecompileTools 1.3 and later require Julia 1.12 while LoweredCodeUtils supports Julia 1.10.

The precompile workload ran directly at the top level of
`src/packagedef.jl`, guarded by `jl_generating_output`. Its variables,
such as `frame` and `edges`, were left as globals of LoweredCodeUtils
and saved in the package image. Code that the workload inferred for
methods of other modules through runtime dispatch was not cached, since
no backedge chain connects it to LoweredCodeUtils, and the workload
could not be skipped.

This change moves the workload to `src/precompile.jl` and runs it with
PrecompileTools. The workload lowers its input code in
`@setup_workload` and calls the LoweredCodeUtils APIs in
`@compile_workload`, which also caches the code inferred through
runtime dispatch. Both blocks are `let` blocks so that their variables
stay local, and users can skip the workload with the
`precompile_workload` preference. As in JuliaInterpreter,
`src/precompile.jl` is included from `src/LoweredCodeUtils.jl`, so
`src/packagedef.jl` still loads without PrecompileTools.

The compat bound of PrecompileTools is 1.2.1, since PrecompileTools 1.3
and later require Julia 1.12 while LoweredCodeUtils supports Julia
1.10.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant