GPU SQL Engine Lost to Single CPU Thread Due to Misconfigured Dispatch Constant
A developer maintaining a GPU-accelerated SQL engine built on DuckDB discovered their Apple Silicon Metal implementation was 1.7x slower than a single CPU thread on a 10-million-row GROUP BY benchmark. By sweeping group cardinality values, they identified a sharp performance cliff between 256 and 1024 groups, pointing to a kernel dispatcher switching between two execution paths. The root cause was a single integer constant — kSlotLockMinGroups set at 1,024 instead of the optimal 131,072 — causing the engine to use the wrong kernel for lower-cardinality workloads. Correcting the constant delivered up to a 3x speedup in affected ranges while all 96 unit tests and 72 SQL tests continued to pass. A secondary investigation revealed the hybrid CPU-GPU planner only routes workloads to the GPU when group counts already exceed the corrected threshold, meaning the bug had never been triggered in real-world queries.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in