ovperf-multinode 0.1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. ovperf/multinode/__init__.py +4 -0
  2. ovperf/multinode/_collector_launcher.c +257 -0
  3. ovperf/multinode/_coordination_node.py +3634 -0
  4. ovperf/multinode/_vendor/__init__.py +4 -0
  5. ovperf/multinode/_vendor/yatp/LICENSE +203 -0
  6. ovperf/multinode/_vendor/yatp/NOTICE +7 -0
  7. ovperf/multinode/_vendor/yatp/VENDOR.json +60 -0
  8. ovperf/multinode/_vendor/yatp/VENDOR.md +36 -0
  9. ovperf/multinode/_vendor/yatp/__init__.py +3 -0
  10. ovperf/multinode/_vendor/yatp/__main__.py +5 -0
  11. ovperf/multinode/_vendor/yatp/alignment.py +230 -0
  12. ovperf/multinode/_vendor/yatp/breakdown.py +183 -0
  13. ovperf/multinode/_vendor/yatp/capture.py +61 -0
  14. ovperf/multinode/_vendor/yatp/charts.js +93 -0
  15. ovperf/multinode/_vendor/yatp/charts.py +133 -0
  16. ovperf/multinode/_vendor/yatp/cli.py +15 -0
  17. ovperf/multinode/_vendor/yatp/docs/contract.md +558 -0
  18. ovperf/multinode/_vendor/yatp/enrichment.py +199 -0
  19. ovperf/multinode/_vendor/yatp/include/yatp/profile_span.h +192 -0
  20. ovperf/multinode/_vendor/yatp/links.py +403 -0
  21. ovperf/multinode/_vendor/yatp/live.html +135 -0
  22. ovperf/multinode/_vendor/yatp/live.py +133 -0
  23. ovperf/multinode/_vendor/yatp/match.py +89 -0
  24. ovperf/multinode/_vendor/yatp/media.py +23 -0
  25. ovperf/multinode/_vendor/yatp/metrics.py +160 -0
  26. ovperf/multinode/_vendor/yatp/profile_span.py +116 -0
  27. ovperf/multinode/_vendor/yatp/report.py +538 -0
  28. ovperf/multinode/_vendor/yatp/serve.py +448 -0
  29. ovperf/multinode/_vendor/yatp/timeline.css +22 -0
  30. ovperf/multinode/_vendor/yatp/timeline.js +799 -0
  31. ovperf/multinode/_vendor/yatp/timeline.py +109 -0
  32. ovperf/multinode/_vendor/yatp/trace_store.py +130 -0
  33. ovperf/multinode/channels.py +214 -0
  34. ovperf/multinode/config.py +220 -0
  35. ovperf/multinode/connections.py +502 -0
  36. ovperf/multinode/coordination.py +1710 -0
  37. ovperf/multinode/cpu_capacity.py +142 -0
  38. ovperf/multinode/flows.py +461 -0
  39. ovperf/multinode/images.py +532 -0
  40. ovperf/multinode/kubernetes.py +1204 -0
  41. ovperf/multinode/measurements.py +285 -0
  42. ovperf/multinode/pytest_plugin.py +42 -0
  43. ovperf/multinode/relink.py +391 -0
  44. ovperf/multinode/series.py +188 -0
  45. ovperf/multinode/session.py +803 -0
  46. ovperf/multinode/spans.py +948 -0
  47. ovperf/multinode/summary.py +1950 -0
  48. ovperf/multinode/tcp.py +1162 -0
  49. ovperf/multinode/telemetry.py +243 -0
  50. ovperf/multinode/verify.py +715 -0
  51. ovperf_multinode-0.1.3.dist-info/METADATA +82 -0
  52. ovperf_multinode-0.1.3.dist-info/RECORD +59 -0
  53. ovperf_multinode-0.1.3.dist-info/WHEEL +4 -0
  54. ovperf_multinode-0.1.3.dist-info/entry_points.txt +3 -0
  55. ovperf_multinode-0.1.3.dist-info/licenses/EXTERNAL-MATERIALS-NOTICE.txt +1 -0
  56. ovperf_multinode-0.1.3.dist-info/licenses/LICENSE +203 -0
  57. ovperf_multinode-0.1.3.dist-info/licenses/THIRD-PARTY-NOTICES.txt +22 -0
  58. ovperf_multinode-0.1.3.dist-info/licenses/src/ovperf/multinode/_vendor/yatp/LICENSE +203 -0
  59. ovperf_multinode-0.1.3.dist-info/licenses/src/ovperf/multinode/_vendor/yatp/NOTICE +7 -0
@@ -0,0 +1,4 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ """Shared support for benchmarks whose components run on several prepared hosts."""
@@ -0,0 +1,257 @@
1
+ /* SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ * SPDX-License-Identifier: Apache-2.0
3
+ * Host-side collector watcher. Linux only.
4
+ *
5
+ * --target PID observes one running process (a container's init) from the
6
+ * host: its container cgroup CPU and process-tree RSS. Exits
7
+ * when the target exits. The workload itself is unchanged.
8
+ * --start-ticks the target's expected start time (/proc/PID/stat field 22);
9
+ * a different process holding the PID is refused.
10
+ * --observer observes the selected physical GPUs of this host.
11
+ * --node-cpu with --observer, also the node's CPU against its capacity.
12
+ * --mig with --observer, also each MIG instance's used memory.
13
+ *
14
+ * Both flush to --output and stop on SIGTERM/SIGINT or after --deadline.
15
+ */
16
+ #define _GNU_SOURCE
17
+ #include <ovperf_collector/ovperf_collector_config.h>
18
+ #include <errno.h>
19
+ #include <math.h>
20
+ #include <poll.h>
21
+ #include <signal.h>
22
+ #include <stdio.h>
23
+ #include <stdlib.h>
24
+ #include <string.h>
25
+ #include <sys/syscall.h>
26
+ #include <time.h>
27
+ #include <unistd.h>
28
+
29
+ /* Kept in step with LAUNCHER_MAX_DEADLINE_S in coordination.py, which checks run_s against it. */
30
+ #define LAUNCHER_MAX_DEADLINE_S (7 * 86400)
31
+
32
+ #ifndef OVPERF_METADATA_PREFIX
33
+ #define OVPERF_METADATA_PREFIX "runtime"
34
+ #endif
35
+
36
+ static volatile sig_atomic_t interrupted;
37
+ static void on_signal(int value) { interrupted = value; }
38
+ static double now(void) {
39
+ struct timespec time;
40
+ clock_gettime(CLOCK_MONOTONIC, &time);
41
+ return (double)time.tv_sec + (double)time.tv_nsec * 1e-9;
42
+ }
43
+ /* Concatenation requires a literal: sizeof must never measure a pointer. */
44
+ #define LITERAL_VIEW(s) ((ovpc_string_t){"" s, sizeof("" s) - 1})
45
+ #define RULE(s, enabled) ovpc_config_entry_metric(LITERAL_VIEW(s), enabled)
46
+
47
+ /* Field 22 of /proc/<pid>/stat: the process start time, in clock ticks after boot. */
48
+ static bool start_ticks(long pid, unsigned long long* ticks) {
49
+ char path[64];
50
+ char line[4096];
51
+ snprintf(path, sizeof path, "/proc/%ld/stat", pid);
52
+ FILE* file = fopen(path, "r");
53
+ if (!file) return false;
54
+ size_t length = fread(line, 1, sizeof line - 1, file);
55
+ fclose(file);
56
+ line[length] = 0;
57
+ char* field = strrchr(line, ')'); /* The command name may contain spaces and parentheses. */
58
+ if (!field) return false;
59
+ char* save = NULL;
60
+ field = strtok_r(field + 1, " ", &save); /* Field 3. */
61
+ int index = 3;
62
+ while (field && index < 22) {
63
+ field = strtok_r(NULL, " ", &save);
64
+ ++index;
65
+ }
66
+ char* end;
67
+ if (!field) return false;
68
+ *ticks = strtoull(field, &end, 10);
69
+ return end != field;
70
+ }
71
+
72
+ /* Every refusal says why: the watcher's log is the only evidence on the node. */
73
+ static int usage(const char* reason, const char* value) {
74
+ fprintf(stderr, "Collector launcher: %s%s%s\n", reason, value ? ": " : "", value ? value : "");
75
+ return 2;
76
+ }
77
+
78
+ static bool positive(const char* text, double maximum, double* out) {
79
+ char* end;
80
+ *out = strtod(text, &end);
81
+ return !*end && isfinite(*out) && *out > 0 && *out <= maximum;
82
+ }
83
+
84
+ struct options {
85
+ const char* output;
86
+ ovpc_string_t devices[16];
87
+ int device_count;
88
+ long target;
89
+ unsigned long long expected_start;
90
+ bool observer;
91
+ bool gpm;
92
+ bool node_cpu;
93
+ bool mig;
94
+ double hz;
95
+ double deadline;
96
+ };
97
+
98
+ /* Only original, NUL-terminated argv values reach here. Their storage survives
99
+ * collector initialization. ARG_MAX bounds scanning without imposing a shorter
100
+ * device identifier limit; it is not a capacity for arbitrary caller buffers. */
101
+ static int add_device(const char* value, struct options* options) {
102
+ if (options->device_count == 16) return usage("at most 16 --gpu devices", NULL);
103
+ long limit = sysconf(_SC_ARG_MAX);
104
+ if (limit <= 0) return usage("cannot determine argument size limit", NULL);
105
+ size_t length = strnlen(value, (size_t)limit);
106
+ if (length == (size_t)limit) return usage("GPU argument exceeds argument size limit", NULL);
107
+ options->devices[options->device_count++] = (ovpc_string_t){value, length};
108
+ return 0;
109
+ }
110
+
111
+ static int parse_value(const char* argument, const char* value, struct options* options) {
112
+ if (!strcmp(argument, "--output")) options->output = value;
113
+ else if (!strcmp(argument, "--hz")) {
114
+ if (!positive(value, 1000, &options->hz)) return usage("--hz must be in (0, 1000]", value);
115
+ } else if (!strcmp(argument, "--deadline")) {
116
+ if (!positive(value, LAUNCHER_MAX_DEADLINE_S, &options->deadline)) return usage("--deadline must be in (0, 7 days] seconds", value);
117
+ } else if (!strcmp(argument, "--target")) {
118
+ char* end;
119
+ options->target = strtol(value, &end, 10);
120
+ if (*end || options->target <= 0 || options->target > 0x7fffffff) return usage("--target must be a positive PID", value);
121
+ } else if (!strcmp(argument, "--start-ticks")) {
122
+ char* end;
123
+ options->expected_start = strtoull(value, &end, 10);
124
+ if (*end || !options->expected_start) return usage("--start-ticks must be a positive start time", value);
125
+ } else if (!strcmp(argument, "--gpu")) {
126
+ return add_device(value, options);
127
+ } else return usage("invalid argument", argument);
128
+ return 0;
129
+ }
130
+
131
+ static int parse_arguments(int argc, char** argv, struct options* options) {
132
+ int i = 1;
133
+ while (i < argc) {
134
+ const char* argument = argv[i++];
135
+ if (!strcmp(argument, "--observer")) options->observer = true;
136
+ else if (!strcmp(argument, "--gpm")) options->gpm = true;
137
+ else if (!strcmp(argument, "--node-cpu")) options->node_cpu = true;
138
+ else if (!strcmp(argument, "--mig")) options->mig = true;
139
+ else {
140
+ if (i == argc) return usage("invalid argument", argument);
141
+ int error = parse_value(argument, argv[i++], options);
142
+ if (error) return error;
143
+ }
144
+ }
145
+ if (!options->output) return usage("--output is required", NULL);
146
+ if (options->observer == (options->target > 0)) return usage("exactly one of --observer and --target is required", NULL);
147
+ if (options->observer && !options->device_count) return usage("--observer needs at least one --gpu", NULL);
148
+ if (!options->observer && (options->device_count || options->gpm || options->node_cpu || options->mig))
149
+ return usage("--gpu, --gpm, --node-cpu and --mig need --observer", NULL);
150
+ if (options->expected_start && !options->target) return usage("--start-ticks needs --target", NULL);
151
+ return 0;
152
+ }
153
+
154
+ static size_t configure(const struct options* options, ovpc_config_entry_t entries[40]) {
155
+ size_t n = 0;
156
+ entries[n++] = ovpc_config_entry_sample_hz(options->hz);
157
+ entries[n++] = ovpc_config_entry_bool(OVPC_CONFIG_COLLECT_GPU, options->observer);
158
+ entries[n++] = ovpc_config_entry_bool(OVPC_CONFIG_COLLECT_GPM, options->gpm);
159
+ entries[n++] = ovpc_config_entry_component(options->observer ? LITERAL_VIEW("runtime-device-observer")
160
+ : LITERAL_VIEW("runtime-process-watcher"));
161
+ entries[n++] = RULE("*", false);
162
+ if (options->observer) {
163
+ const ovpc_string_t selected[] = {LITERAL_VIEW("gpu.nvml_*"), LITERAL_VIEW("gpu.memory.*"),
164
+ LITERAL_VIEW("gpu.process.*"), LITERAL_VIEW("gpu.clock_sm_mhz"),
165
+ LITERAL_VIEW("gpu.clock_events.*"), LITERAL_VIEW("gpu.temperature_c")};
166
+ for (size_t i = 0; i < sizeof selected / sizeof selected[0]; ++i)
167
+ entries[n++] = ovpc_config_entry_metric(selected[i], true);
168
+ /* Opt-in: the node's CPU against its capacity (a pod's quota, not the machine), beside its GPUs. */
169
+ if (options->node_cpu) entries[n++] = RULE("cpu.node.utilization_ratio", true);
170
+ /* Opt-in: each MIG instance's own used memory (unprivileged, the physical GPU reports none). */
171
+ if (options->mig) entries[n++] = RULE("gpu.mig.memory.used_bytes", true);
172
+ if (options->gpm) {
173
+ entries[n++] = RULE("gpu.sm_occupancy_ratio", true);
174
+ entries[n++] = RULE("gpu.graphics_util_ratio", true);
175
+ entries[n++] = RULE("gpu.dram_bw_util_ratio", true);
176
+ }
177
+ for (int i = 0; i < options->device_count; ++i) entries[n++] = ovpc_config_entry_gpu_device(options->devices[i]);
178
+ } else {
179
+ entries[n++] = ovpc_config_entry_target_pid(options->target);
180
+ entries[n++] = RULE("cpu.cgroup.utilization_ratio", true);
181
+ entries[n++] = RULE("process.tree.*", true);
182
+ entries[n++] = RULE("process.memory.rss_bytes", true);
183
+ entries[n++] = RULE("cpu.process.*", true);
184
+ }
185
+ return n;
186
+ }
187
+
188
+ static int wait_for_stop(int pidfd, double deadline) {
189
+ int infrastructure_error = 0;
190
+ const double stop_at = deadline > 0 ? now() + deadline : INFINITY;
191
+ while (!infrastructure_error && !interrupted && now() < stop_at) {
192
+ if (pidfd >= 0) {
193
+ /* Readable once the target has exited. */
194
+ struct pollfd exited = {.fd = pidfd, .events = POLLIN};
195
+ const int ready = poll(&exited, 1, 20);
196
+ if (ready > 0) break;
197
+ if (ready < 0 && errno != EINTR) infrastructure_error = 1;
198
+ } else {
199
+ const struct timespec pause = {.tv_nsec = 20000000};
200
+ nanosleep(&pause, NULL);
201
+ }
202
+ }
203
+ return infrastructure_error;
204
+ }
205
+
206
+ int main(int argc, char** argv) {
207
+ struct options options = {.hz = 10};
208
+ int argument_error = parse_arguments(argc, argv, &options);
209
+ if (argument_error) return argument_error;
210
+ struct sigaction action = {0};
211
+ action.sa_handler = on_signal;
212
+ sigemptyset(&action.sa_mask);
213
+ sigaction(SIGTERM, &action, NULL);
214
+ sigaction(SIGINT, &action, NULL);
215
+ /* A pidfd cannot be confused with a later process that reuses the PID. */
216
+ int pidfd = -1;
217
+ if (options.target) {
218
+ pidfd = (int)syscall(SYS_pidfd_open, (pid_t)options.target, 0);
219
+ if (pidfd < 0) { fprintf(stderr, "Target process %ld unavailable: %s\n", options.target, strerror(errno)); return 125; }
220
+ /* Checked after pidfd_open: a match means the pidfd holds the expected process,
221
+ * not one that took over the PID after the caller looked it up. */
222
+ unsigned long long started;
223
+ if (options.expected_start && (!start_ticks(options.target, &started) || started != options.expected_start)) {
224
+ fprintf(stderr, "Target process %ld is no longer the expected process\n", options.target);
225
+ return 125;
226
+ }
227
+ }
228
+ ovpc_config_entry_t entries[40];
229
+ ovpc_config_t config = {entries, configure(&options, entries)};
230
+ if (ovpc_initialize(&config).status != OVPC_API_SUCCESS) {
231
+ const char* error = ovpc_get_last_error().ptr; /* May be NULL by contract. */
232
+ fprintf(stderr, "Collector initialization failed: %s\n", error ? error : "no detail");
233
+ return 125;
234
+ }
235
+ char identity[80];
236
+ if (options.target) {
237
+ snprintf(identity, sizeof identity, "%ld", options.target);
238
+ ovpc_set_metadata(OVPERF_METADATA_PREFIX ".role_pid", identity);
239
+ ovpc_set_metadata(OVPERF_METADATA_PREFIX ".cpu_scope", "role container cgroup, observed from the host");
240
+ ovpc_set_metadata(OVPERF_METADATA_PREFIX ".rss_scope", "process tree rooted at the role container's init process");
241
+ }
242
+ snprintf(identity, sizeof identity, "%.9f", now() - ovpc_now());
243
+ ovpc_set_metadata(OVPERF_METADATA_PREFIX ".monotonic_origin_s", identity);
244
+ /* Each auto-flush rewrites the whole recording on the sampling thread, so its
245
+ * cost grows with the recording. At one second it outgrew a 100 ms sample
246
+ * slot after ~8 minutes and dropped a sample every flush; at 30 s a long
247
+ * recording still misses a slot per flush, 30 times less often. Stop and
248
+ * deadline still flush everything. */
249
+ int infrastructure_error = ovpc_set_auto_flush(options.output, 30).status != OVPC_API_SUCCESS;
250
+ infrastructure_error |= ovpc_start_collection().status != OVPC_API_SUCCESS;
251
+ if (!infrastructure_error) infrastructure_error = wait_for_stop(pidfd, options.deadline);
252
+ ovpc_stop_collection();
253
+ infrastructure_error |= ovpc_flush_now().status != OVPC_API_SUCCESS;
254
+ ovpc_shutdown();
255
+ if (pidfd >= 0) close(pidfd);
256
+ return infrastructure_error ? 125 : 0;
257
+ }