Skip to content

Commit 157191c

Browse files
authored
Add bpf-cupti-event-scale-factor flag for GPU ringbuf sizing (#3197)
Bumps ebpf-profiler to pick up the cupti_events ringbuf sizing knob and the ringbuf-full drop metric (parca-dev/opentelemetry-ebpf-profiler#309), then: - wires tracer.Config.CUPTIEventScaleFactor via a new --bpf-cupti-event-scale-factor flag (power-of-two over the 1 MiB base; default 0 = unchanged), so GPU nodes running CUDA graph workloads can grow the buffer when they see cuda.errors.ringbuf_full. - registers the cuda.errors.ringbuf_full drop metric for export.
1 parent 0d3d537 commit 157191c

5 files changed

Lines changed: 43 additions & 20 deletions

File tree

flags/flags.go

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ const (
5858
defaultMapScaleFactor = 0
5959
// 1TB of executable address space
6060
maxMapScaleFactor = 8
61+
62+
// Power-of-two scale factor over the 1 MiB cupti_events ringbuf base.
63+
// 0 = 1 MiB (current default), 8 = 256 MiB. Bump on GPU nodes running CUDA
64+
// graph workloads that show cuda.errors.ringbuf_full.
65+
defaultCUPTIEventScaleFactor = 0
66+
maxCUPTIEventScaleFactor = 8
6167
)
6268

6369
func Parse() (Flags, error) {
@@ -67,11 +73,13 @@ func Parse() (Flags, error) {
6773
// Build Kong options
6874
kongOptions := []kong.Option{
6975
kong.Vars{
70-
"hostname": hostname,
71-
"default_cpu_sampling_frequency": strconv.Itoa(defaultCPUSamplingFrequency),
72-
"default_map_scale_factor": strconv.Itoa(defaultMapScaleFactor),
73-
"max_map_scale_factor": strconv.Itoa(maxMapScaleFactor),
74-
"default_memlock_rlimit": "0", // No limit by default. (flag is deprecated)
76+
"hostname": hostname,
77+
"default_cpu_sampling_frequency": strconv.Itoa(defaultCPUSamplingFrequency),
78+
"default_map_scale_factor": strconv.Itoa(defaultMapScaleFactor),
79+
"max_map_scale_factor": strconv.Itoa(maxMapScaleFactor),
80+
"default_cupti_event_scale_factor": strconv.Itoa(defaultCUPTIEventScaleFactor),
81+
"max_cupti_event_scale_factor": strconv.Itoa(maxCUPTIEventScaleFactor),
82+
"default_memlock_rlimit": "0", // No limit by default. (flag is deprecated)
7583
},
7684
}
7785

@@ -82,11 +90,13 @@ func Parse() (Flags, error) {
8290
// Create a new parser with YAML configuration support
8391
parser, err := kong.New(&flags,
8492
kong.Vars{
85-
"hostname": hostname,
86-
"default_cpu_sampling_frequency": strconv.Itoa(defaultCPUSamplingFrequency),
87-
"default_map_scale_factor": strconv.Itoa(defaultMapScaleFactor),
88-
"max_map_scale_factor": strconv.Itoa(maxMapScaleFactor),
89-
"default_memlock_rlimit": "0",
93+
"hostname": hostname,
94+
"default_cpu_sampling_frequency": strconv.Itoa(defaultCPUSamplingFrequency),
95+
"default_map_scale_factor": strconv.Itoa(defaultMapScaleFactor),
96+
"max_map_scale_factor": strconv.Itoa(maxMapScaleFactor),
97+
"default_cupti_event_scale_factor": strconv.Itoa(defaultCUPTIEventScaleFactor),
98+
"max_cupti_event_scale_factor": strconv.Itoa(maxCUPTIEventScaleFactor),
99+
"default_memlock_rlimit": "0",
90100
},
91101
kong.Configuration(kongyaml.Loader, flags.ConfigPath),
92102
)
@@ -196,6 +206,11 @@ func (f Flags) Validate() ExitCode {
196206
f.BPF.MapScaleFactor, maxMapScaleFactor)
197207
}
198208

209+
if f.BPF.CUPTIEventScaleFactor < 0 || f.BPF.CUPTIEventScaleFactor > maxCUPTIEventScaleFactor {
210+
return ParseError("cupti_events scaling factor %d out of range (0-%d)",
211+
f.BPF.CUPTIEventScaleFactor, maxCUPTIEventScaleFactor)
212+
}
213+
199214
if f.BPF.VerifierLogLevel > 2 {
200215
return ParseError("Invalid eBPF verifier log level: %d", f.BPF.VerifierLogLevel)
201216
}
@@ -404,12 +419,13 @@ type FlagsHidden struct {
404419
}
405420

406421
type FlagsBPF struct {
407-
VerboseLogging bool `help:"Enable verbose BPF logging from eBPF code to ebpf trace_pipe."`
408-
LogTracePipe bool `help:"Copy bpf trace_pipe to info logging."`
409-
EventsBufferSize uint32 `default:"8192" help:"Size in pages of the events buffer."`
410-
MapScaleFactor int `default:"${default_map_scale_factor}" help:"Scaling factor for eBPF map sizes. Every increase by 1 doubles the map size. Increase if you see eBPF map size errors. Default is ${default_map_scale_factor} corresponding to 4GB of executable address space, max is ${max_map_scale_factor}."`
411-
VerifierLogLevel uint32 `default:"0" help:"Log level of the eBPF verifier output (0,1,2). Default is 0."`
412-
VerifierLogSize int `default:"0" help:"[deprecated] Unused."`
422+
VerboseLogging bool `help:"Enable verbose BPF logging from eBPF code to ebpf trace_pipe."`
423+
LogTracePipe bool `help:"Copy bpf trace_pipe to info logging."`
424+
EventsBufferSize uint32 `default:"8192" help:"Size in pages of the events buffer."`
425+
MapScaleFactor int `default:"${default_map_scale_factor}" help:"Scaling factor for eBPF map sizes. Every increase by 1 doubles the map size. Increase if you see eBPF map size errors. Default is ${default_map_scale_factor} corresponding to 4GB of executable address space, max is ${max_map_scale_factor}."`
426+
CUPTIEventScaleFactor int `default:"${default_cupti_event_scale_factor}" help:"Power-of-two scale factor over the 1 MiB cupti_events ringbuf base for GPU profiling. Every increase by 1 doubles the buffer. Increase on GPU nodes running CUDA graph workloads that show cuda.errors.ringbuf_full. Default is ${default_cupti_event_scale_factor} (1 MiB), max is ${max_cupti_event_scale_factor}."`
427+
VerifierLogLevel uint32 `default:"0" help:"Log level of the eBPF verifier output (0,1,2). Default is 0."`
428+
VerifierLogSize int `default:"0" help:"[deprecated] Unused."`
413429
}
414430

415431
type FlagsOfflineMode struct {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,4 @@ require (
189189
sigs.k8s.io/yaml v1.4.0 // indirect
190190
)
191191

192-
replace go.opentelemetry.io/ebpf-profiler => github.com/parca-dev/opentelemetry-ebpf-profiler v0.0.0-20260617152842-7fd00ff31304
192+
replace go.opentelemetry.io/ebpf-profiler => github.com/parca-dev/opentelemetry-ebpf-profiler v0.0.202624-0.20260630131910-2f051e9329b8

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ github.com/opencontainers/selinux v1.13.1/go.mod h1:S10WXZ/osk2kWOYKy1x2f/eXF5ZH
317317
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
318318
github.com/parca-dev/oomprof v0.1.6 h1:potfd09aphNKqsIF54ZsiddTvksVMjQiaKnczFOsVGM=
319319
github.com/parca-dev/oomprof v0.1.6/go.mod h1:iqI6XrmiNWOa8m2vEIKo+GtQrqbWCMLFpBWuk8RuAPs=
320-
github.com/parca-dev/opentelemetry-ebpf-profiler v0.0.0-20260617152842-7fd00ff31304 h1:mGMlNzOTNcV/BDHTtEoiCi5vbySU5DcQHFj6COY1GpE=
321-
github.com/parca-dev/opentelemetry-ebpf-profiler v0.0.0-20260617152842-7fd00ff31304/go.mod h1:VFrOyobZJf5qmHlPXImJXlfVWi5xb4SHx7cIqU1G908=
320+
github.com/parca-dev/opentelemetry-ebpf-profiler v0.0.202624-0.20260630131910-2f051e9329b8 h1:jqSPuVGxrzV/HU5VpD9x4doIhemE/EhJAZO3HoZic6I=
321+
github.com/parca-dev/opentelemetry-ebpf-profiler v0.0.202624-0.20260630131910-2f051e9329b8/go.mod h1:PIWChzqW1XvgamjPyaKO82tGO44rkiXhdDN8S9zoRq8=
322322
github.com/parca-dev/usdt v0.0.2 h1:bpKQycQ++zV8pwkMaJSxZS07XnEXqO3rkHcLYFJDTl4=
323323
github.com/parca-dev/usdt v0.0.2/go.mod h1:bjh3OTksk+pyP7WsHWlRKWaMSJTUr0gx0piZ/tAv6/w=
324324
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0=

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ func mainWithExitCode() flags.ExitCode {
468468
IncludeTracers: includeTracers,
469469
SamplesPerSecond: f.Profiling.CPUSamplingFrequency,
470470
MapScaleFactor: f.BPF.MapScaleFactor,
471+
CUPTIEventScaleFactor: f.BPF.CUPTIEventScaleFactor,
471472
FilterErrorFrames: !f.Profiling.EnableErrorFrames,
472473
KernelVersionCheck: !f.Hidden.IgnoreUnsafeKernelVersion,
473474
BPFVerifierLogLevel: f.BPF.VerifierLogLevel,

metrics/all.go

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)