fix #46778, precompile() for abstract but compileable signatures#47259
Merged
JeffBezanson merged 1 commit intomasterfrom Nov 16, 2022
Merged
fix #46778, precompile() for abstract but compileable signatures#47259JeffBezanson merged 1 commit intomasterfrom
precompile() for abstract but compileable signatures#47259JeffBezanson merged 1 commit intomasterfrom
Conversation
ac69e97 to
b7d0d6a
Compare
vtjnash
reviewed
Oct 21, 2022
vtjnash
reviewed
Oct 21, 2022
b7d0d6a to
eebacab
Compare
Member
|
Bump! Good to go? |
Member
|
Something doesn't seem right with the caching of these signatures in a sysimage. As an example, I add a specific precompile statement for the problematic method in #46778: diff --git a/contrib/generate_precompile.jl b/contrib/generate_precompile.jl
index 295b24d22e..abc887d94d 100644
--- a/contrib/generate_precompile.jl
+++ b/contrib/generate_precompile.jl
@@ -186,6 +186,18 @@ if Libdl !== nothing
"""
end
+Serialization = get(Base.loaded_modules,
+ Base.PkgId(Base.UUID("9e88b42a-f829-5b0c-bbe9-9e923198166b"), "Serialization"),
+ nothing)
+if Serialization !== nothing
+ @info "Precompiling deserialization..."
+ hardcoded_precompile_statements *= """
+ precompile(Tuple{typeof(Serialization.deserialize), Serialization.Serializer{Base.GenericIOBuffer{Array{UInt8, 1}}}, DataType})
+
+ """
+end
+
+
Test = get(Base.loaded_modules,
Base.PkgId(Base.UUID("8dfed614-e22c-5e08-85e1-65c5234f0b40"), "Test"),
nothing)I build a Julia with this, and then I create a serialized file: using Serialization
struct MyStruct
x::String
end
s = MyStruct("foo")
serialize("file.jls", s)Now, I run Julia with julia> using Serialization
julia> struct MyStruct
x::String
end
julia> @time deserialize(IOBuffer(read("file.jls")));
precompile(Tuple{typeof(Serialization.deserialize), Serialization.Serializer{Base.GenericIOBuffer{Array{UInt8, 1}}}, DataType})
0.022934 seconds (11.89 k allocations: 800.115 KiB, 98.08% compilation time)
julia> @time deserialize(IOBuffer(read("file.jls")));
0.000084 seconds (28 allocations: 2.008 KiB)The compile time is not removed and the signature printed is exactly the one that was supposed to be cached in the |
Member
Author
|
Oh, it looks like generate_precompile has an explicit check for this: |
Member
|
Oh... |
9e66b47 to
1d4e49f
Compare
KristofferC
pushed a commit
that referenced
this pull request
Nov 17, 2022
KristofferC
pushed a commit
that referenced
this pull request
Nov 17, 2022
51 tasks
26 tasks
JeffBezanson
added a commit
that referenced
this pull request
Mar 30, 2023
Since #47259 most Vararg precompile statements actually work, so they should be allowed, and for ones that don't work there's no harm in trying them.
KristofferC
added a commit
to JuliaLang/PackageCompiler.jl
that referenced
this pull request
Apr 23, 2023
KristofferC
added a commit
to JuliaLang/PackageCompiler.jl
that referenced
this pull request
Apr 23, 2023
KristofferC
added a commit
to JuliaLang/PackageCompiler.jl
that referenced
this pull request
Apr 23, 2023
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
fix #46778