Repository navigation
Improve precompilation #359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c5ce724
Add a precompilation workload
JamesWrigley 417a0fa
Make some inference improvements
JamesWrigley 5d87c28
Apply suggestions from code review
fingolfin 94ca47c
Apply suggestion from @github-actions[bot]
fingolfin d81d7ba
Apply suggestions from code review
fingolfin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -110,4 +110,6 @@ function test_all( | |
| end | ||
| end | ||
|
|
||
| include("precompile.jl") | ||
|
|
||
| end # module | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| using PrecompileTools: @compile_workload | ||
|
|
||
| # Create a minimal fake package to test. Needs to be at the top-level because | ||
| # it's a module. | ||
| module _FakePackage | ||
| export fake_function | ||
| fake_function() = 1 | ||
| end | ||
|
|
||
| @compile_workload begin | ||
| redirect_stdout(devnull) do | ||
| test_all( | ||
| _FakePackage; | ||
| ambiguities = false, | ||
| project_extras = false, | ||
| stale_deps = false, | ||
| deps_compat = false, | ||
| persistent_tasks = false, | ||
| ) | ||
| end | ||
|
|
||
| # Explicitly precompile the tests that need a real package module | ||
| precompile(test_ambiguities, (Vector{Module},)) | ||
| precompile(test_project_extras, (Module,)) | ||
| precompile(test_stale_deps, (Module,)) | ||
| precompile(test_deps_compat, (Module,)) | ||
|
|
||
| # Create a fake package directory for testing persistent_tasks. We go to | ||
| # some effort to precompile this because it takes the longest due to Pkg | ||
| # calls and running precompilation in a subprocess. | ||
| mktempdir() do dir | ||
| project_file = joinpath(dir, "Project.toml") | ||
| write( | ||
| project_file, | ||
| """ | ||
| name = "AquaFakePackage" | ||
| uuid = "5a23b2e7-8c45-4b1c-9d3f-7a6b4c8d9e0f" | ||
| version = "0.1.0" | ||
|
|
||
| [deps] | ||
| Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
|
||
| [compat] | ||
| Test = "1" | ||
| julia = "1" | ||
| """, | ||
| ) | ||
|
|
||
| srcdir = joinpath(dir, "src") | ||
| mkdir(srcdir) | ||
| write(joinpath(srcdir, "AquaFakePackage.jl"), "module AquaFakePackage end") | ||
|
|
||
| # The meat of the compilation latency comes from this function. Running | ||
| # test_persistent_tasks() directly is more difficult because it takes a | ||
| # Module and then gets the package directory, and we don't want to load | ||
| # the fake package. | ||
| precompile_wrapper(project_file, 10, quote end) | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's to make it type-stable. I could also have changed the type annotation to
Union{String, Nothing}, but I felt that sticking with only strings is simpler.