Repository navigation
fix: count_min_sketch allocated its hash seeds with std::allocator - #559
Open
rustyconover wants to merge 1 commit into
Open
rustyconover wants to merge 1 commit into
rustyconover wants to merge 1 commit into
Conversation
hash_seeds was a std::vector<uint64_t> with the default allocator, so every sketch made with a custom allocator also allocated from the global heap, and so did its copies. Rebind the sketch's allocator for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
count_min_sketchkeeps its per-row hash seeds instd::vector<uint64_t> hash_seeds, with the default allocator. So a sketch built with a custom allocator still allocates from the global heap, and so do its copies. This makes the vector use the sketch's allocator, rebound touint64_t, and constructs it with_allocator.Test
Added
CountMin sketch test allocator: hash seeds use the sketch's allocatortocount_min_allocation_test.cpp. Withtest_allocator, a sketch with 5 hashes and 100 buckets, and a copy of it, must allocate the counters and the hash seeds through the allocator. Without the fix it fails with4000 == 4040: the 40 missing bytes are the 5 seeds. With it, all Count-Min tests pass.We found this in the DuckDB DataSketches extension. There, aggregate states keep their sketches in DuckDB's per-query arena so they count toward the memory limit, and memory allocated outside the arena is never accounted for.
🤖 Generated with Claude Code