-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Implement support for object caching through pkgimages #47184
Conversation
d4d4f80
to
927aacb
Compare
a6a0ca7
to
2ed4acd
Compare
2ed4acd
to
dc393ec
Compare
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.
Nice!
d3ecb28
to
112c66b
Compare
This is in slack, but I believe here its more proper. While trying CSV.jl, it does precompile, however when calling
This is because we hit a value that went through Line 2868 in a405d41
I couldn't get the exact type of the value becaue it jl_typename_str didn't work on
|
To explain what's happening, the key part of uniquing is actually Lines 2795 to 2859 in a405d41
To explain what's happening: a package image contains a few objects that need to be unique in the system. A good example is a datatype like So during the uniquing process as developed in #44527, what we do is the following:
All that work is done in the section of code I linked to above. The one exception is to ensure that the first usage of an item is the "reconstructable blob" in the image. This is handled by some fairly complicated shenanigans in order of traversal in |
I found another issue, but a bit different.
With rr I got that |
I mentioned it on Slack, but reporting this also here: on this branch I currently see a noticeable increase in precompilation time. I used for testing a fresh environment with only
This PR:
On the other hand on this branch we have a sensible improvement in loading times + TTFX, so increase in precompilation times (which is a one-off for non-dev users, who are probably the majority) is not too bad, but it'd be great to investigate why there is this increase here (in #44527 the difference is much smaller). |
dc8618c
to
83ef0ee
Compare
@nanosoldier |
Your package evaluation job has completed - possible new issues were detected. A full report can be found here. |
26f23c8
to
8c4036e
Compare
0dde76e
to
c1a38b4
Compare
jlpkg, MPIMapReduce, CORBITS, Evolutionary passed locally. |
Locally tested:
|
Party time! |
Out of curiosity: Is this still 1.9 material? |
yes. |
This implements caching native code in "package images" (pkgimages). We now write two serialization files, one ending in `*.ji` and the other with the platform dynamic library extension (e.g., `*.so`). The `*.ji` contains "extended" header information (include the source-code dump for Revise), whereas the dynamic library includes the Julia objects, including LLVM-generated native code. Native code is compiled once during precompilation and then a second time to build a "clean" module. When we find an edge to an external function (already cached in anloaded pkgimage), we emit a global variable which we will patch during loading with the address of the function to call. This allows us to leverage the standard multiversioning capabilities. Co-authored-by: Tim Holy <tim.holy@gmail.com> Co-authored-by: Kristoffer Carlsson <kristoffer.carlsson@chalmers.se> Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com> Co-authored-by: Ian Butterworth <i.r.butterworth@gmail.com> Co-authored-by: Max Horn <max@quendi.de> Co-authored-by: Michael Schlottke-Lakemper <michael@sloede.com> Co-authored-by: Alex Ames <alexander.m.ames@gmail.com> (cherry picked from commit a2db90f)
Personally, I'm flattered you all waited until my birthday to merge, but congrats on all the work here! Huge step forward for Julia! |
This implements caching native code in "package images" (pkgimages). We now write two serialization files, one ending in `*.ji` and the other with the platform dynamic library extension (e.g., `*.so`). The `*.ji` contains "extended" header information (include the source-code dump for Revise), whereas the dynamic library includes the Julia objects, including LLVM-generated native code. Native code is compiled once during precompilation and then a second time to build a "clean" module. When we find an edge to an external function (already cached in anloaded pkgimage), we emit a global variable which we will patch during loading with the address of the function to call. This allows us to leverage the standard multiversioning capabilities. Co-authored-by: Tim Holy <tim.holy@gmail.com> Co-authored-by: Kristoffer Carlsson <kristoffer.carlsson@chalmers.se> Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com> Co-authored-by: Ian Butterworth <i.r.butterworth@gmail.com> Co-authored-by: Max Horn <max@quendi.de> Co-authored-by: Michael Schlottke-Lakemper <michael@sloede.com> Co-authored-by: Alex Ames <alexander.m.ames@gmail.com>
I completely agree! Ideally, there should be a blog post about it that highlights the advantages for all users (and points at possible issues and how to address them, eg, invalidations) when 1.9 is released. |
That's now standard protocol, I'm sure that will happen this time. |
try | ||
ccall(:jl_check_pkgimage_clones, Cvoid, (Ptr{Cchar},), clone_targets) | ||
return true | ||
catch | ||
return false | ||
end |
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 are we using try/catch for normal control flow?
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.
The way check_clones works is by throwing an exception, and I understand to little of the code to effectively refactor it.
.ji
contains a full-header and all the source for Revise.so
That contains all the data and the native codeThis uses
jl_code_instance_t
as the relocation key and emits a table into the binary codeagainst which to later perform relocation.
TODO:
link_image_cmd
jl_validate_cache_file