Skip to content

Serialization: fast path for serialize(_, ::Union)#61724

Open
adienes wants to merge 1 commit intoJuliaLang:masterfrom
adienes:serialization_union_spec
Open

Serialization: fast path for serialize(_, ::Union)#61724
adienes wants to merge 1 commit intoJuliaLang:masterfrom
adienes:serialization_union_spec

Conversation

@adienes
Copy link
Copy Markdown
Member

@adienes adienes commented May 6, 2026

fixes #58007

PR:

julia> using Serialization, BenchmarkTools, LinearAlgebra

julia> const sig = Base.unwrap_unionall(methods(LinearAlgebra.herk_wrapper!).ms[1].sig);

julia> const sig_bytes = (io = IOBuffer(); serialize(io, sig); take!(io));

julia> @benchmark serialize(IOBuffer(), $sig)
BenchmarkTools.Trial: 10000 samples with 1 evaluation per sample.
 Range (min  max):  141.166 μs   2.343 ms  ┊ GC (min  max): 0.00%  92.20%
 Time  (median):     142.625 μs              ┊ GC (median):    0.00%
 Time  (mean ± σ):   144.458 μs ± 22.477 μs  ┊ GC (mean ± σ):  0.15% ±  0.92%

 Memory estimate: 13.95 KiB, allocs estimate: 253.

julia> @benchmark deserialize(IOBuffer($sig_bytes))
BenchmarkTools.Trial: 10000 samples with 1 evaluation per sample.
 Range (min  max):   97.292 μs   7.686 ms  ┊ GC (min  max): 0.00%  97.60%
 Time  (median):      99.083 μs              ┊ GC (median):    0.00%
 Time  (mean ± σ):   102.759 μs ± 99.222 μs  ┊ GC (mean ± σ):  1.58% ±  1.68%

 Memory estimate: 34.73 KiB, allocs estimate: 744.

master:

julia> const sig_bytes = (io = IOBuffer(); serialize(io, sig); take!(io))
# wait 10 minutes then give up
^C^C^C^C^C^CWARNING: Force throwing a SIGINT
ERROR: InterruptException:

@adienes adienes added performance Must go faster stdlib Julia's standard library labels May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Must go faster stdlib Julia's standard library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Serializer takes very long to serialize bulky type

1 participant