-
-
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
fix #46778, precompile()
for abstract but compileable signatures
#47259
Conversation
ac69e97
to
b7d0d6a
Compare
b7d0d6a
to
eebacab
Compare
Bump! Good to go? |
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 |
Oh, it looks like generate_precompile has an explicit check for this:
|
Oh... |
9e66b47
to
1d4e49f
Compare
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.
fix #46778