ANN_BENCH: integrate NVTX statistics#1529
Merged
rapids-bot[bot] merged 11 commits intorapidsai:mainfrom Nov 13, 2025
Merged
Conversation
Contributor
Author
|
As an example, I've build CAGRA-for-HNSW using only CPU events with a wiki-1M dataset, exported a CSV, and generated the breakdown bar plot using Google Sheets: nsys launch --trace=nvtx ./cpp/build/bench/ann/ANN_BENCH \
--build --force \
--benchmark_min_time=20s \
--benchmark_min_warmup_time=0.1 \
--benchmark_counters_tabular \
--benchmark_out_format=csv \
--benchmark_out=cagra-hnsw-build.csv \
--benchmark_filter=cuvs_cagra_hnsw.* \
--override_kv=dataset_memory_type:\"host\" \
wiki-1M-cagra-hnsw.json
|
tfeher
approved these changes
Nov 12, 2025
Contributor
tfeher
left a comment
There was a problem hiding this comment.
Thanks Artem for the PR! This is neat, this will be very useful for understanding more details about how time is spent during benchmarks. The PR looks good to me.
Contributor
|
This seems like it could be quite useful for other RAPIDS libraries too. I wonder if we could put this somewhere that's easy to reuse in others too, WDYT? |
Contributor
Author
|
In theory yes, it's rather modular and pluggable in any executable. I'm just not sure where one would keep the code if not just copy-pasting |
Contributor
Author
|
/merge |
enp1s0
pushed a commit
to enp1s0/cuvs
that referenced
this pull request
Nov 16, 2025
Add the aggregate reporting of NVTX ranges in the output of benchmark executable. ### Usage ```bash # Measure the CPU and GPU runtime of all NVTX ranges nsys launch --trace=cuda,nvtx <ANN_BENCH with arguments> # Measure only the CPU runtime of all NVTX ranges nsys launch --trace=nvtx <ANN_BENCH with arguments> # Do not measure/report any NVTX ranges <ANN_BENCH with arguments> # Do not measure/report any NVTX ranges within benchmark, but use nsys profiling as usual nsys profile ... <ANN_BENCH with arguments> ``` ### Implementation The PR adds a single module `nvtx_stats.hpp` to the benchmark executable; there are no changes to the library at all. The program leverages NVIDIA Nsight Systems CLI to collect and export NVTX statistics and then SQLite API to aggregate it into the benchmark state: 1. Detect if run via `nsys launch`; if so, call `nsys start` / `nsys stop` around benchmark loop; otherwise do nothing. 2. If the report is generated, read it and query all NVTX events and the GPU correlation data using SQLite 3. Aggregate the NVTX events by their short names (without arguments to reduce the number of columns) 4. Add them to the benchmark performance counters with the same averaging strategy as the global CPU/GPU runtime. ### Performance cost If the benchmark is **not** run using `nsys launch`, there's virtually zero overhead in the new functionality. Otherwise, there are overheads: 1. Usual nsys profiling overheads (minimized by disabling unused information via `nsys start` CLI internally). This affects the reported performance the same way as normal nsys profiling does (especially if cuda tracing is enabled). 2. One or more data collection/exporting events per benchmark case. These add some extra time to the benchmark time, but do not affect the counters (they are not the part of the benchmark loop) Closes rapidsai#1367 Authors: - Artem M. Chirkin (https://github.com/achirkin) Approvers: - Tamas Bela Feher (https://github.com/tfeher) URL: rapidsai#1529
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.

Add the aggregate reporting of NVTX ranges in the output of benchmark executable.
Usage
Implementation
The PR adds a single module
nvtx_stats.hppto the benchmark executable; there are no changes to the library at all.The program leverages NVIDIA Nsight Systems CLI to collect and export NVTX statistics and then SQLite API to aggregate it into the benchmark state:
nsys launch; if so, callnsys start/nsys stoparound benchmark loop; otherwise do nothing.Performance cost
If the benchmark is not run using
nsys launch, there's virtually zero overhead in the new functionality.Otherwise, there are overheads:
nsys startCLI internally). This affects the reported performance the same way as normal nsys profiling does (especially if cuda tracing is enabled).Closes #1367