-
Notifications
You must be signed in to change notification settings - Fork 180
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
Reduce the time-to-first-request by adding pregenerated precompile statements #805
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #805 +/- ##
==========================================
- Coverage 83.06% 74.79% -8.28%
==========================================
Files 32 40 +8
Lines 3089 2567 -522
==========================================
- Hits 2566 1920 -646
- Misses 523 647 +124 ☔ View full report in Codecov by Sentry. |
f1b95f2
to
636a47e
Compare
636a47e
to
73b1344
Compare
end | ||
""") | ||
println(io, """ | ||
@static if Base.VERSION < v"1.9-" |
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.
This is great, thanks for the PR @DilumAluthge ! I am surprised that this is only enabled for Julia 1.9 and up. We found that adding precompile
calls also gave improvements in Julia 1.8.
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.
@DilumAluthge why this is only enabled for 1.9 and 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.
So, I was under the impression that without JuliaLang/julia#43990, we can't cache CodeInstances
from other packages, and thus the benefit of this would be far less noticeable.
Awesome! I would also like to add precompile statements for HTTP's server abilities, but this PR gives me all the tools to do that in a future PR 😊 |
How about writing to a release branch based on the version mentioned in |
I thought this type of explicit |
Depends on the use-case. If |
precompile(Tuple{typeof(Base.bytesavailable), Sockets.TCPSocket}) | ||
precompile(Tuple{typeof(Base.eof), Sockets.TCPSocket}) | ||
precompile(Tuple{typeof(Base.alloc_buf_hook), Sockets.TCPSocket, UInt64}) | ||
precompile(Tuple{Base.var"#readcb_specialized#671", Sockets.TCPSocket, Int64, UInt64}) |
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.
precompile(Tuple{Base.var"#readcb_specialized#671", Sockets.TCPSocket, Int64, UInt64}) |
This line causes
(HTTP) pkg> precompile
Precompiling project...
✗ HTTP
0 dependencies successfully precompiled in 4 seconds. 4 already precompiled.
ERROR: The following 1 direct dependency failed to precompile:
HTTP [cd3eb016-35fb-5094-929b-558a96fad6f3]
Failed to precompile HTTP [cd3eb016-35fb-5094-929b-558a96fad6f3] to /home/rik/.julia/compiled/v1.9/HTTP/jl_pwtQbZ.
ERROR: LoadError: UndefVarError: #readcb_specialized#671 not defined
Stacktrace:
[1] _precompile()
@ HTTP ~/git/HTTPDilum/src/precompile.jl:46
[2] top-level scope
@ ~/git/HTTPDilum/src/HTTP.jl:627
[3] include
@ ./Base.jl:427 [inlined]
[4] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
@ Base ./loading.jl:1423
[5] top-level scope
@ stdin:1
in expression starting at /home/rik/git/HTTPDilum/src/HTTP.jl:1
in expression starting at stdin:1
on Julia 1.9.0-DEV.428.
@DilumAluthge It's best to do compilation time benchmarks with
In this case, I do think that your benchmark is valid though. I could reproduce similar numbers on Julia 1.9.0-DEV.428: master
This PR
|
73b1344
to
a0df8f8
Compare
Summary
This pull request makes two changes:
Description
This pull request reduces the time to first
HTTP.get("https://example.com/")
as shown in the following table. All times are in seconds.master
dpa/precompile
All measurements were taken using Julia version
1.9.0-DEV.165
:Note: this pull request does not make any web requests when the user does
Pkg.precompile()
orimport HTTP
.List of time measurements
Time measurements for the
master
branch (click to expand)Time measurements for the
dpa/precompile
branch (click to expand)How to regenerate the list of precompile statements
To regenerate the list of precompile statements, there are two options:
Precompile
workflow, and manually trigger a new workflow run. This will automatically open a pull request to update the precompile statements.julia --project contrib/precompile_generate.jl