signature_type_by_tt allocates on every launch on Julia 1.14
メンテナーはふだん 1 日以内に返信
関連するプルリクエストがすでにマージされています。
- #1025 @maleadt による — マージ済み
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 25/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- julia
- 領域
- backend, performance
調査の方向性
Start in the signature_type_by_tt implementation and compare its Julia 1.14 path with the pre-1.14 tuple splatting path. The reproducer in the issue measures allocations for sig_splat and sig_map; use it to verify the allocation difference and check behavior when dispatch_key changes type parameters. Done means avoiding the reported per-lookup allocations while preserving the needed dispatch behavior; pull request #1025 is already open.
索引モデルが issue の本文から書いたものです。
説明
On Julia 1.14 (where Core.TypeEgal is defined), signature_type_by_tt builds the signature with map(dispatch_key, u.parameters):
@inline function signature_type_by_tt(ft::Type, tt::Type)
u = Base.unwrap_unionall(tt)::DataType
return Base.rewrap_unionall(Tuple{dispatch_key(ft), map(dispatch_key, u.parameters)...}, tt)
end
Unlike Tuple{ft, u.parameters...}, which the pre-1.14 branch uses and which is folded to a constant for a constant tt, map over the SimpleVector isn't folded: it allocates a Vector{Any} and constructs the tuple type at run time. Since methodinstance calls this on every lookup, every kernel launch through a cached cufunction/clfunction/... allocates, proportionally to the number of arguments.
This shows up in KernelAbstractions' POCL back-end, where a launch with 4 scalar arguments allocates 128 bytes more than on Julia 1.13 and one with 40 arguments 416 bytes more (Profile.Allocs: Memory{Any}, Vector{Any} and a CorruptType from signature_type_by_tt < methodinstance < clfunction), failing KA's "POCL launch with many arguments" test on nightly.
Reproducer without GPUCompiler (same results on 1.13 and 1.14.0-DEV):
@inline function dispatch_key(@nospecialize(t))
if Base.isType(t)
u = Base.type_parameter(t)
!Base.has_free_typevars(u) && return isdefined(Core, :TypeEgal) ? Core.TypeEgal{u} : Type{u}
end
return t
end
@inline sig_splat(ft::Type, tt::Type) = Tuple{ft, (tt::DataType).parameters...}
@inline sig_map(ft::Type, tt::Type) = Tuple{dispatch_key(ft), map(dispatch_key, (tt::DataType).parameters)...}
kern(args...) = nothing
const TT = Tuple{Vector{Int}, ntuple(_ -> Int, 40)...}
f_splat() = sig_splat(typeof(kern), TT)
f_map() = sig_map(typeof(kern), TT)
f_splat(); f_map()
@show @allocated(f_splat()) # 0
@show @allocated(f_map()) # 432
Taking the splatting path unless ft or one of the parameters is a Type{...} (the only case where dispatch_key changes anything) avoids the allocations.
- 主要言語
- Julia
- スター
- 189
- フォーク
- 71
- 平均マージ
- 1日 12時間
- マージ済み PR(30日)
- 72
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
JuliaGPU/GPUCompiler.jl のほかの issue
-
spirv
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
JuliaGPU/GPUCompiler.jl#1008 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
JuliaGPU/GPUCompiler.jl#1050 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
JuliaGPU/GPUCompiler.jl#1049 ·
メンテナーはふだん 1 日以内に返信
-
`julia_datalayout` is invalidated by ChainRulesCore, adding ~2 s to the first kernel compile対応中かも @maleadt が今日担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
JuliaGPU/GPUCompiler.jl#1048 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 1〜2日 初心者へのやさしさ 48/100
JuliaGPU/GPUCompiler.jl#1032 ·
メンテナーはふだん 1 日以内に返信
JuliaGPU/GPUCompiler.jl の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
bug help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
JuliaGeometry/Meshes.jl#1469 ·
メンテナーはふだん 1 日以内に返信
-
distributed 🕸️
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
CliMA/Oceananigans.jl#6295 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
CI: two jobs fail on the new ubuntu-latest (Ubuntu 26.04) runner image対応中かも @bjarthur が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
mojaie/MolecularGraph.jl#151 ·