-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Rework approach to cudf-streaming bloom filter sizing #23067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ff29c5a
d8b3e84
160bf30
04042dd
68e7c7f
26dd172
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <cuco/bloom_filter_policies.cuh> | ||
|
|
||
| #include <cstdint> | ||
|
|
||
| namespace cudf { | ||
|
|
||
| /** | ||
| * @brief Policy describing the Apache Arrow Block-Split Bloom Filter layout. | ||
| * | ||
| * Uses cuco's `parametric_filter_policy` with the Apache Arrow layout: 256-bit blocks (8 x | ||
| * `uint32_t`), 8 fingerprint bits per key, fully horizontal add (Theta=8), and fully vertical | ||
| * contains (Phi=8). This layout is bit-compatible with Apache Arrow. | ||
| * | ||
| * @tparam Hash The hash function used to generate a hash for each key. | ||
| */ | ||
| template <typename Hash> | ||
| using arrow_filter_policy = | ||
| cuco::parametric_filter_policy<Hash, std::uint32_t, 8, 8, 8, 1, 1, 8, false, false>; | ||
|
|
||
| } // namespace cudf | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,40 +28,58 @@ struct device_bloom_filter { | |
| /** | ||
| * @brief Create a filter. | ||
| * | ||
| * @param num_blocks Number of blocks in the filter. | ||
| * @param filter_size Filter storage size in bytes. Must be a positive multiple of the filter | ||
| * block size and no greater than the maximum supported by the filter policy. | ||
| * @param seed Seed used for hashing each value. | ||
| * @param storage Storage to view as a bloom filter, must be appropriately | ||
| * initialized. | ||
| */ | ||
| device_bloom_filter(std::size_t num_blocks, std::uint64_t seed, void* storage); | ||
| device_bloom_filter(std::size_t filter_size, std::uint64_t seed, void* storage); | ||
|
|
||
| /** | ||
| * @brief Create a read-only filter. | ||
| * | ||
| * @param num_blocks Number of blocks in the filter. | ||
| * @param filter_size Filter storage size in bytes. Must be a positive multiple of the filter | ||
| * block size and no greater than the maximum supported by the filter policy. | ||
| * @param seed Seed used for hashing each value. | ||
| * @param storage View of storage, must be appropriately initialized. | ||
| * | ||
| * @return A const-qualified bloom filter viewing the underlying storage. | ||
| */ | ||
| static device_bloom_filter const view(std::size_t num_blocks, | ||
| static device_bloom_filter const view(std::size_t filter_size, | ||
| std::uint64_t seed, | ||
| void const* storage); | ||
|
|
||
| /** | ||
| * @brief Create uninitialized storage for a filter. | ||
| * | ||
| * @param num_blocks Number of blocks in the filter. | ||
| * @param filter_size Filter storage size in bytes. Must be a positive multiple of the filter | ||
| * block size and no greater than the maximum supported by the filter policy. | ||
| * @param stream CUDA stream for device operations. | ||
| * @param mr Memory resource for allocations. | ||
| * | ||
| * @return Unique pointer to a device buffer containing storage for the requested | ||
| * number of filter blocks. | ||
| * filter size. | ||
| */ | ||
| static std::unique_ptr<rmm::device_buffer> storage(std::size_t num_blocks, | ||
| static std::unique_ptr<rmm::device_buffer> storage(std::size_t filter_size, | ||
| rmm::cuda_stream_view stream, | ||
| rmm::device_async_resource_ref mr); | ||
|
|
||
| /** | ||
| * @brief Find the largest valid filter size no greater than a byte count. | ||
| * | ||
| * @param size Byte count to align. | ||
| * @return Largest valid filter size less than or equal to `size`. | ||
| */ | ||
| [[nodiscard]] static std::size_t aligned_size(std::size_t size) noexcept; | ||
|
|
||
| /** | ||
| * Return the largest storage size supported by the filter policy. | ||
| * | ||
| * Maximum valid filter size in bytes. | ||
| */ | ||
| [[nodiscard]] static std::size_t max_size() noexcept; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sleeepyjack I think this is the kind of utility, along with the corresponding validation checks, that we should expose in cuco rather than expecting users to implement themselves. Similar to how we provide utilities/constructors for configuring HLL from different perspectives, such as target standard deviation or sketch size in bytes, we could offer the same level of convenience here. |
||
|
|
||
| /** | ||
| * @brief Add values to the filter. | ||
| * | ||
|
|
@@ -111,14 +129,6 @@ struct device_bloom_filter { | |
| */ | ||
| [[nodiscard]] std::size_t size() const noexcept; | ||
|
|
||
| /** | ||
| * @brief @return Number of blocks to use if the filter should fit in a given L2 cache | ||
| * size. | ||
| * | ||
| * @param l2size Size of the L2 cache in bytes. | ||
| */ | ||
| [[nodiscard]] static std::size_t fitting_num_blocks(std::size_t l2size) noexcept; | ||
|
|
||
| private: | ||
| std::size_t num_blocks_; ///< Number of blocks used in the filter. | ||
| std::uint64_t seed_; ///< Seed used when hashing values. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.