Repository navigation
Description
Loading KernelAbstractions 0.10 takes about twice as long as 0.9:
julia -e 'using KernelAbstractions' |
packages in Manifest | invalidated method instances | |
|---|---|---|---|
bare julia -e '' |
94 ms | ||
| 0.9.45 | 301 ms | 32 | 105 |
| 0.10.0 | 613 ms | 70 | 2800 |
(Julia 1.13.1, macOS, median of 7 runs, fresh environment with only KA.)
This propagates to back-ends: Metal.jl's import time went from 1.81 s to 1.99 s when it moved to KA 0.10 (JuliaGPU/Metal.jl#994), even though Metal already loaded GPUCompiler and now only weakly depends on KA (GPUArrays 12 still loads it).
There are two separate causes.
Dependencies of the POCL back-end
@time_imports shows that KA now unconditionally loads everything the POCL back-end needs: GPUCompiler (and through it REPL, ~55 ms), CompilerCaching/LMDB, four tree_sitter_*_jlls, pocl_standalone_jll with Hwloc, XML2, Libiconv and Zstd, SPIRV_LLVM_Backend_jll, SPIRV_Tools_jll, SPIRVIntrinsics, which pulls in SpecialFunctions and CompilerSupportLibraries_jll (26 ms in its __init__), and Random123/RandomNumbers. GPU back-ends never use any of this. For Metal.jl, which already loads GPUCompiler, the remaining cost is about 80 ms, a good part of it per-package loading overhead.
show(::IO, ::Type{GeneratedKernelError{Msg}})
A single method, src/macros.jl:117, accounts for nearly all of the invalidations: its tree has 2984 children, because it is more specific than show(::IO, ::Type) for every caller that was inferred with an abstract type. Removing it brings using KernelAbstractions from 611 to 555 ms.
The method also crashes Julia when the type parameter is not bound:
julia> using KernelAbstractions
julia> println(Vector{KernelAbstractions.GeneratedKernelError{Msg}} where Msg)
Array{ERROR: UndefVarError: `Msg` not defined in static parameter matching
...
fatal: error thrown and no exception handler available.This happens in practice: SnoopCompile hits it when printing the invalidation tree for this very method, and so does methods(show, (IO, Type{<:KernelAbstractions.GeneratedKernelError})).
The default printing already includes the message, e.g., KernelAbstractions.GeneratedKernelError{Symbol("generator failed: x is not defined")}, so the simplest fix may be to remove the method.
Activity
maleadt commentedon Oct 13, 2026
(Claude-filed, I need to investigate myself later, but wanted a record.)