Freeing memory from a finalizer waits for the GPU
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- julia
- 领域
- backend, performance
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Julia
- 星标
- 218
- 派生
- 36
- 平均合并
- 1 天 6 小时
- 30 天内合并 PR
- 57
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
JuliaGPU/oneAPI.jl 的其他 Issue
-
Require SPIRVIntrinsics 1.5.1 for local arrays of isbits unions可能已有人在做 @maleadt 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 30/100
维护者通常 1 天内回复
-
libraries upstream
难度 4/5 1-2 天 新手友好度 22/100
JuliaGPU/oneAPI.jl#703 · 2 条评论 ·
维护者通常 1 天内回复
-
ci
难度 5/5 一周以上 新手友好度 35/100
JuliaGPU/oneAPI.jl#663 · 1 个 reaction ·
维护者通常 1 天内回复
-
runtime upstream
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 1 天内回复
-
ci kernels upstream
难度 4/5 3-5 天 新手友好度 35/100
JuliaGPU/oneAPI.jl#538 · 2 条评论 ·
维护者通常 1 天内回复
查看 JuliaGPU/oneAPI.jl 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
legend-exp/LegendDataManagement.jl#232 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
EnzymeAD/Reactant.jl#3569 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
astroautomata/SymbolicRegression.jl#783 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 73/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 90/100
维护者通常 1 天内回复