Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[ENHANCEMENT]: `for_each` on containers without duplicates keeps probing after the match

Closed Beginner friendly
#858 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

A pull request for this has already been merged.

  • #859 by @PointKernel — merged

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp
Domain
databases

Research direction

Start in the scalar and cooperative for_each of open_addressing_ref_impl, at the equal_result::EQUAL case, and read how allows_duplicates is used there. The proposed change stops probing after the callback for non-duplicate containers and leaves the multiset and multimap paths alone. Run the static_set, static_map, static_multiset and static_multimap tests; done means they pass and hit lookups get faster.

Written by the indexing model from the issue text.

Description

Is your feature request related to a problem? Please describe.

On static_set/static_map, ref.for_each(key, cb) keeps probing after calling cb on the match, up to the next empty slot, although a key is held at most once there (find and contains already stop at the match). Every hit pays for the rest of its cluster:

// static_map<uint64_t, uint64_t> ref with cuco::op::for_each, 64 dependent lookups per thread
for (int i = 0; i < 64; ++i) {
  uint64_t next = ~0ull;
  ref.for_each(key, [&](auto const& slot) { next = slot.second; });
  key = next;
}

RTX 4090, load factor 0.5, 167,936 threads, 2^17 slots: hits take 0.589 ms, 0.226 ms with the change below; misses are unchanged (0.34 ms).

Describe the solution you'd like

End the probe at the match when the container has no duplicates, in the scalar and cooperative for_each of open_addressing_ref_impl:

             case detail::equal_result::EQUAL: {
               callback_op(bucket_slots[i()]);
+              if constexpr (not allows_duplicates) { should_return = true; }  // cooperative: empty = true

The multiset and multimap paths are unchanged. With it the static_set, static_map, static_multiset and static_multimap tests pass (415/415, sm_89).

🤖 Generated with Claude Code

Dominant language
Cuda
Stars
671
Forks
122
Avg merge
4d 19h
Merged PRs (30d)
10

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NVIDIA/cuCollections

All issues in NVIDIA/cuCollections

Similar issues

More Databases issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.