fix(lookup): free charset_len_buffer (GPU buffer leak aborting multi-config-group lookups) - #129
Merged
Merged
Conversation
charset_len_buffer was created in host_thread_false_alarm() and host_thread_precompute() but freed in neither — only the batch-precompute path released it. Every GPU false-alarm/precompute invocation therefore leaked one GPU memory buffer. Across a multi-config-group lookup these accumulate on the device until clCreateContext() fails with CL_OUT_OF_HOST_MEMORY (-6), aborting lookups partway through (observed at config group ~7 on a full-size table campaign). Root cause confirmed with live create/release counters wrapping the OpenCL allocator: buffer count climbed monotonically per config group (ctx/queue/ program/kernel stayed balanced) and went flat after adding these frees. Shared host code, so this affected all backends (OpenCL/CUDA/Metal). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
bandrel
force-pushed
the
fix/opencl-charset-len-buffer-leak
branch
from
July 24, 2026 15:03
beec310 to
9252d5e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
Multi-config-group lookups abort partway through with
Failed to create context: -6(CL_OUT_OF_HOST_MEMORY) — observed at config group ~7 of a full-size table campaign.Root cause
charset_len_bufferis created in bothhost_thread_false_alarm()andhost_thread_precompute()but freed in neither — only the batch-precompute path (batch_precompute_all_hashes) released it. Every GPU false-alarm / per-hash-precompute invocation leaked one GPU memory buffer. Across config groups these accumulate on the device untilclCreateContext()can no longer allocate.Evidence
Wrapped the OpenCL create/release entry points with live counters and dumped them per config group:
Only
bufclimbed (monotonic, ~one per GPU false-alarm invocation). After adding the frees,bufstays flat at 0 across all 10 groups and the full run completes (exit=0, 0 context errors, potential-match counts unchanged).Fix
Add the missing
CLFREEBUFFER(charset_len_buffer)to both cleanup paths. Shared host code, so this affected all backends (OpenCL/CUDA/Metal).Verification
make linux,make cuda,make macosall build.🤖 Generated with Claude Code