Skip to content
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

Remove the shared state and the mutex from NVTX internals #2310

Merged
merged 2 commits into from
May 15, 2024

Conversation

achirkin
Copy link
Contributor

Until now, raft has stored a map of NVTX colors (annotation -> color) to avoid using the same color for different annotations and keep using the same color for the same annotations. This map is a shared state.
During an extensive ANN_BENCH throughput testing it has turned out that the mutex guarding the map can sometimes become a bottleneck when the number of concurrent threads is really large (>~ 256). This PR replaces the unordered map and the mutex guarding it with a deterministic hash value of the annotation instead (which is stateless).

Pros:

  • No shared state, no mutexes.
  • Assigns the same colors to the same annotations across program runs.

Cons:

  • Sometimes different annotations can have the same color (hash collisions).

@achirkin achirkin added 3 - Ready for Review improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels May 14, 2024
@achirkin achirkin requested a review from a team as a code owner May 14, 2024 09:41
@github-actions github-actions bot added the cpp label May 14, 2024
Copy link
Contributor

@tfeher tfeher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Artem for the PR, looks good, just a small update in docstring is missing!

cpp/include/raft/core/detail/nvtx.hpp Show resolved Hide resolved
@achirkin achirkin requested a review from tfeher May 14, 2024 15:32
Copy link
Contributor

@tfeher tfeher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update, LGTM!

@achirkin
Copy link
Contributor Author

/merge

@rapids-bot rapids-bot bot merged commit f3806f1 into rapidsai:branch-24.06 May 15, 2024
68 of 70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Ready for Review cpp improvement Improvement / enhancement to an existing function non-breaking Non-breaking change
Projects
Development

Successfully merging this pull request may close these issues.

3 participants