Freeing memory from a finalizer waits for the GPU
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- julia
- Ambito
- backend, performance
Direzione di ricerca
Start with the finalizer and free policy in src/pool.jl, then read the GC workaround in test/execution.jl ("freeing memory may wait for the stream on some stacks"). Compare DEFER_FREE behavior on the rolling stack with the LTS stack's policy limitations described in the issue. Done means finalizer cleanup avoids the reported GPU wait and deadlock on each supported stack, with tests covering memory reclamation.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Freeing memory from a finalizer waits for all GPU work in the process. The finalizer of an array that isn't sub-allocated (device memory over 1 MiB, and all shared and host memory) frees it with zeMemFreeExt and the BLOCKING_FREE policy (src/pool.jl). Our kernels declare indirect access, so NEO considers every allocation in use by every kernel, and the free waits until everything submitted so far has executed, not only the work using that buffer.
That stalls whatever thread happens to collect garbage, and deadlocks when the GPU work waits for a task on that thread. The test suite already works around it by disabling GC while a kernel waits on the host (test/execution.jl, "freeing memory may wait for the stream on some stacks").
Measured on an Iris Xe (NEO 26.35), with a ~1 s kernel running on another task's stream, and the release triggered from a finalizer on thread 1 (medians of 7):
| release | blocks the collecting thread | launch on another thread |
|---|---|---|
| device array, 4 KiB (sub-allocated) | 0.02 ms | 0.15 ms |
| device array, 64 MiB | 863 ms | 0.15 ms |
| shared array, 4 KiB / 64 MiB | 861 / 861 ms | 0.14 / 0.16 ms |
| host array, 4 KiB / 64 MiB | 861 / 865 ms | 0.14 / 0.16 ms |
zeMemFree without a policy |
857 ms | 0.17 ms |
zeMemFreeExt with DEFER_FREE |
0.03 ms | 0.15 ms |
busy ZeImmediateCommandList |
902 ms | – |
| modules, kernels, queues, lists, events, fences | ≤ 0.1 ms | – |
With the stream waiting on an event that a task on thread 1 signals, collecting a host array (3/3), a 64 MiB shared array (3/3) or a 64 MiB device array (2/3) on that thread hangs until a watchdog signals the event.
Unlike with CUDA (JuliaGPU/CUDA.jl#3318), launches on other threads aren't held up, and only memory frees and the busy immediate-list drain wait. So rather than deferring every release, it should be enough to free with DEFER_FREE on the rolling stack. NEO keeps deferred allocations on a list that it only processes on a later free, so reclaiming memory needs to trigger one. The LTS stack reportedly doesn't honor the free policies (see the comment in src/pool.jl), so there the blocking free, and the unbounded synchronize_all_streams before it, would have to move out of the finalizer instead.
- Lingua principale
- Julia
- Stelle
- 218
- Fork
- 36
- Merge medio
- 1g 4h
- 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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di JuliaGPU/oneAPI.jl
-
libraries upstream
Difficoltà 4/5 1-2 giorni Idoneità per principianti 22/100
JuliaGPU/oneAPI.jl#703 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
ci
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
JuliaGPU/oneAPI.jl#663 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
runtime upstream
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 1 giorno
-
ci kernels upstream
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
JuliaGPU/oneAPI.jl#538 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
installation upstream
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
JuliaGPU/oneAPI.jl#503 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di JuliaGPU/oneAPI.jl
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
OpenSourceAWE/SymbolicAWEModels.jl#431 ·
I maintainer di solito rispondono entro 1 giorno
-
Make PDAQP an optional extraAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
EnzymeAD/Reactant.jl#3549 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
WaterLily-jl/WaterLily-Examples#46 · 1 commento ·