Serialization: replace `findfirst`-esque loop with static lookup table (#61730)
for to make that we get better performance
no tags are changed, just the way we compute them.
```julia
julia> using Serialization, BenchmarkTools
julia> syms = [Symbol("sym_$i") for i in 1:5_000];
julia> types = repeat(Type[Int, Float64, String, Symbol, Bool, Module, Tuple, Array], 500);
# PR
julia> @benchmark serialize(buf, $syms) setup = (buf = IOBuffer())
BenchmarkTools.Trial: 10000 samples with 1 evaluation per sample.
Range (min … max): 232.000 μs … 1.445 ms ┊ GC (min … max): 0.00% … 79.35%
Time (median): 244.500 μs ┊ GC (median): 0.00%
Time (mean ± σ): 254.755 μs ± 69.008 μs ┊ GC (mean ± σ): 3.03% ± 7.87%
julia> @benchmark serialize(buf, $types) setup = (buf = IOBuffer())
BenchmarkTools.Trial: 10000 samples with 1 evaluation per sample.
Range (min … max): 227.916 μs … 2.377 ms ┊ GC (min … max): 0.00% … 0.00%
Time (median): 239.042 μs ┊ GC (median): 0.00%
Time (mean ± σ): 243.924 μs ± 42.565 μs ┊ GC (mean ± σ): 0.58% ± 3.23%
```
vs master
```julia
julia> @benchmark serialize(buf, $syms) setup = (buf = IOBuffer())
BenchmarkTools.Trial: 9629 samples with 1 evaluation per sample.
Range (min … max): 475.250 μs … 70.392 ms ┊ GC (min … max): 0.00% … 99.26%
Time (median): 494.042 μs ┊ GC (median): 0.00%
Time (mean ± σ): 517.532 μs ± 1.010 ms ┊ GC (mean ± σ): 4.23% ± 5.37%
julia> @benchmark serialize(buf, $types) setup = (buf = IOBuffer())
BenchmarkTools.Trial: 10000 samples with 1 evaluation per sample.
Range (min … max): 265.084 μs … 5.768 ms ┊ GC (min … max): 0.00% … 94.76%
Time (median): 275.791 μs ┊ GC (median): 0.00%
Time (mean ± σ): 279.091 μs ± 61.669 μs ┊ GC (mean ± σ): 0.72% ± 3.53%
```
draft written by claude and then substantial fixes + rewritten by me. A
Andy Dienes committed
388624ef697cd4451ff36010bff8df94d326285f
Parent: cc9d286
Committed by GitHub <noreply@github.com>
on 5/30/2026, 12:31:35 PM