{
  "id": 2388948,
  "title": "My GPU Database Lost to a Single CPU Thread. The Bug Was One Constant, 128x Too Small",
  "url": "https://urgent.news/2026/08/21/my-gpu-database-lost-to-a-single-cpu-thread-the-bug-was-one-constant",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-08-21T14:33:50.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/aiexplore369zoho/my-gpu-database-lost-to-a-single-cpu-thread-the-bug-was-one-constant-128x-too-small-45hk"
  },
  "original_language": "en",
  "account": "A GPU SQL engine maintained by the reporter suffered a performance issue when running benchmarks on Apple Silicon. The GPU took 1.7 times longer than a single CPU thread processing the same workload. The bug was traced back to a single integer constant used in the slot-lock kernel, which was 128 times too small.\n\nThe issue was discovered by systematically sweeping the group cardinality parameter in the workload. The reporter found that when the group cardinality was between 256 and 1024, the GPU performance dropped significantly, taking 2.4 times longer than the CPU. This sudden slowdown was caused by a change in the algorithm from using a radix-opt path to a slot-lock path.\n\nThe slot-lock kernel builds 4096 fixed hash partitions, each with threadgroup-resident slot tables. However, when the group cardinality is as low as 1,024, all the partitions hash into the same handful of slots, causing thousands of threads to serialize behind slot locks and significantly slowing down the processing.\n\nThe reporter fixed the issue by changing the constant from 1024 to 131,072. This adjustment eliminated the performance regression and improved the GPU's speed relative to the CPU in most cases. The reporter also confirmed that this bug was not being triggered in real-world scenarios through the main application's dispatch logic, making it a rare situation where the buggy code was only exercised during the benchmark process.",
  "summary": "This is a submission for DEV's Summer Bug Smash: Smash Stories powered by Sentry . I maintain a GPU SQL engine — a DuckDB community extension that runs aggregates and GROUP BY on Apple Silicon via Metal. Last night I ran its own benchmark and got a result that should not be possible for a GPU database: gpudb-groupby-bench rows=10000000 groups=1024 [CPU] single-threaded std::unordered_map median…",
  "key_points": [
    "GPU SQL engine experienced performance issue on Apple Silicon",
    "Bug caused by integer constant 128 times too small in slot-lock kernel",
    "Fix involved changing constant from 1024 to 131,072"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}