KernelAbstractions 0.10 doubles load time

Aperta
#889 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Ambito
performance

Direzione di ricerca

The crash and most of the invalidations come from the show(::IO, ::Type{GeneratedKernelError{Msg}}) method at src/macros.jl:117; start there and check that the default printing of GeneratedKernelError{...} still shows the message. Reproduce the crash with println(Vector{KernelAbstractions.GeneratedKernelError{Msg}} where Msg) before and after removing or fixing the method. The POCL dependency-loading part needs maintainer design input, so leave it out of a first contribution.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

installation latency pocl regression

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.

Lingua principale
Julia
Stelle
533
Fork
90
Merge medio
1g 14h
PR unite (30g)
55

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di JuliaGPU/KernelAbstractions.jl

Tutte le issue di JuliaGPU/KernelAbstractions.jl

Issue simili

Altre issue su Julia

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.