NVIDIA / NVIDIA/cuCollections

Size computation slows bulk insert significantly

Open
#237 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P1: Should have type: feature request
Dominant language
Cuda
Stars
667
Forks
120
Avg merge
7d 5h
Merged PRs (30d)
4

Description

The size computation requires a small memcpy from device to host and then a synchronization. Each one is the cause of serious performance degradation.

https://github.com/NVIDIA/cuCollections/blob/8786234a38a4d1283c6dc2011e45d14801510725/include/cuco/detail/static_map.inl#L149-L151

The synchronization is bad because it means that other unrelated streams are unable to do work.

The memcpy is bad because future copies are queued behind this one in architectures that have a limited number of cuda copy engines.

I was able to get a significant performance improvement by deleting these lines.

There ought to be a better way to compute size. Perhaps a lazy method. If this is too difficult, you might consider using templates to allow the user to choose to not maintain size_ at all! Use templates to change the type of size_ from int to a struct that has no members. That way it doesn't take up any space. Provide no methods on this struct so that the size_ doesn't get accidentally used. It will still use some space on the host but that seems like no big deal.

https://github.com/NVIDIA/cuCollections/issues/237#tasklist-block-efc3d0dd-74a4-4f46-b10e-d6fde965d057

Contributor guide

Open the contributing guide

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.

Research direction

Start with include/cuco/detail/static_map.inl at lines 149-151 and profile bulk insertion to confirm the device-to-host memcpy and synchronization costs. Compare alternatives for computing or avoiding size maintenance, then verify that bulk insert no longer incurs the reported per-operation overhead without breaking size-related behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
performance
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.