Skip to content

Develop an Nsight System plugin to profile network bandwidth - #999

Open
kingcrimsontianyu wants to merge 22 commits into
rapidsai:mainfrom
kingcrimsontianyu:network-monitor
Open

Develop an Nsight System plugin to profile network bandwidth#999
kingcrimsontianyu wants to merge 22 commits into
rapidsai:mainfrom
kingcrimsontianyu:network-monitor

Conversation

@kingcrimsontianyu

@kingcrimsontianyu kingcrimsontianyu commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

When developing and optimizing remote I/O, a commonly asked question is: how do I know the achieved bandwidth of my application? While nsys does offer network-related features, limitations exist:

  • --nic-metrics: Requires OFED/InfiniBand dependency that cannot be fulfilled on many systems, including g7e.8xlarge.
  • --enable=network_interface: Shows raw counter instead of bandwidth value. Does not register signals and therefore always returns non-zero exit code.

This PR develops an nsys plugin to allow flexible, generic NIC bandwidth profiling without the above limitations.

@copy-pr-bot

copy-pr-bot Bot commented Jul 6, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@kingcrimsontianyu kingcrimsontianyu added improvement Improves an existing functionality non-breaking Introduces a non-breaking change python Affects the Python API of KvikIO c++ Affects the C++ API of KvikIO Needs build-infra Requires input from the build infrastructure team labels Jul 6, 2026
@kingcrimsontianyu

kingcrimsontianyu commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Sample UI

Below is an example of the NIC bandwidth profile in nsys UI.

image

@kingcrimsontianyu

Copy link
Copy Markdown
Contributor Author

Sample documentation

Screenshot 2026-07-07 at 01-43-09 Profiling — kvikio 26 08 00 documentation

@kingcrimsontianyu
kingcrimsontianyu marked this pull request as ready for review July 7, 2026 05:44
@kingcrimsontianyu
kingcrimsontianyu requested review from a team as code owners July 7, 2026 05:44

@wence- wence- left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

flushing some small comments

Comment thread cpp/nsys_plugins/nic/kvikio_nic_nsys_plugin.cpp Outdated
Comment on lines +56 to +58
// Set from a signal handler for a clean shutdown.
volatile std::sig_atomic_t g_stop = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this can be:

std::atomic_flag g_stop = ATOMIC_FLAG_INIT;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ref says the following. So I've left it default constructed.

This macro is no longer needed since default constructor of std::atomic_flag initializes it to clear state. It is kept for the compatibility with C.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Great to learn about std::atomic_flag.

// loop breaks and the process exits cleanly with code 0 instead of an abnormal termination. Also
// catch SIGINT to have the same clean exit for Ctrl-C.
extern "C" {
static void kvikio_nic_handle_signal(int /*signum*/) { g_stop = 1; }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

And this:

g_stop.test_and_set();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. Passed the relaxed memory ordering.

Comment thread cpp/nsys_plugins/nic/kvikio_nic_nsys_plugin.cpp Outdated
auto prev_time = clock::now();
auto next_deadline = prev_time;

while (stop == 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

while (!g_stop.test()) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, and passed the relaxed memory ordering.

Comment thread cpp/nsys_plugins/nic/kvikio_nic_nsys_plugin.cpp Outdated
@kingcrimsontianyu

Copy link
Copy Markdown
Contributor Author

@wence- Thanks! These are great suggestions. I didn't know the modern C++ way of doing signal handling, so this is a good learning experience.

@madsbk madsbk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks @kingcrimsontianyu

Comment thread cpp/nsys_plugins/nic/kvikio_nic_nsys_plugin.cpp Outdated
Comment thread cpp/CMakeLists.txt
option(KvikIO_BUILD_EXAMPLES "Configure CMake to build examples" ON)
option(KvikIO_BUILD_TESTS "Configure CMake to build tests" ON)
option(KvikIO_REMOTE_SUPPORT "Configure CMake to build with remote IO support" ON)
option(KvikIO_BUILD_NSYS_PLUGIN "Configure CMake to build the Nsight Systems NIC plugin" ON)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we want to build this by default? I guess, yes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. I hope to have it built by default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Affects the C++ API of KvikIO improvement Improves an existing functionality Needs build-infra Requires input from the build infrastructure team non-breaking Introduces a non-breaking change python Affects the Python API of KvikIO

Projects

Status: Burndown

Development

Successfully merging this pull request may close these issues.

5 participants