Skip to content

Commit f2d2f6c

Browse files
committed
Remove demangling in favor of backend demanging
1 parent 5f3160c commit f2d2f6c

2 files changed

Lines changed: 7 additions & 15 deletions

File tree

interpreter/gpu/cuda.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"unique"
99
"unsafe"
1010

11-
"github.com/ianlancetaylor/demangle"
1211
log "github.com/sirupsen/logrus"
1312
"go.opentelemetry.io/ebpf-profiler/host"
1413
"go.opentelemetry.io/ebpf-profiler/interpreter"
@@ -344,19 +343,13 @@ func (f *gpuTraceFixer) prepTrace(st *SymbolizedCudaTrace, ev *CuptiTimingEvent)
344343
out.Trace.CustomLabels["cuda_id"] = strconv.FormatUint(uint64(ev.Id), 10)
345344
}
346345

347-
// Extract kernel name from timing event, demangle, and update the CUDA frame.
346+
// Extract kernel name from timing event and update the CUDA frame.
348347
nameBytes := ev.KernelName[:]
349348
if idx := bytes.IndexByte(nameBytes, 0); idx >= 0 {
350349
nameBytes = nameBytes[:idx]
351350
}
352351
if len(nameBytes) > 0 {
353-
mangledStr := libpf.Intern(unsafe.String(unsafe.SliceData(nameBytes), len(nameBytes)))
354-
funcName := mangledStr
355-
if demStr, err := demangle.ToString(
356-
mangledStr.String(), demangle.NoParams, demangle.NoEnclosingParams); err == nil {
357-
funcName = libpf.Intern(demStr)
358-
}
359-
352+
funcName := libpf.Intern(unsafe.String(unsafe.SliceData(nameBytes), len(nameBytes)))
360353
fi := st.CUDAFrameIdx
361354
out.Trace.Frames[fi] = unique.Make(libpf.Frame{
362355
Type: out.Trace.Frames[fi].Value().Type,

interpreter/gpu/cuda_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,12 @@ func TestAddTraceAndTimes(t *testing.T) {
242242
assert.Equal(t, "0", out.Trace.CustomLabels["cuda_device"])
243243
assert.Equal(t, "7", out.Trace.CustomLabels["cuda_stream"])
244244

245-
// Verify the CUDA frame got the demangled kernel name and zeroed AddressOrLineno.
245+
// Verify the CUDA frame got the kernel name and zeroed AddressOrLineno.
246246
cudaFrame := out.Trace.Frames[0].Value()
247247
assert.Equal(t, libpf.CUDAKernelFrame, cudaFrame.Type)
248248
assert.Equal(t, libpf.AddressOrLineno(0), cudaFrame.AddressOrLineno,
249249
"correlation ID should be zeroed in output")
250-
assert.Contains(t, cudaFrame.FunctionName.String(), "myKernel",
251-
"kernel name should be demangled")
250+
assert.Equal(t, "_Z9myKernelPfS_i", cudaFrame.FunctionName.String())
252251
}
253252

254253
func TestAddTimeThenTrace(t *testing.T) {
@@ -293,7 +292,7 @@ func TestAddTimeThenTrace(t *testing.T) {
293292
assert.Equal(t, "1", out.Trace.CustomLabels["cuda_device"])
294293

295294
cudaFrame := out.Trace.Frames[0].Value()
296-
assert.Contains(t, cudaFrame.FunctionName.String(), "square")
295+
assert.Equal(t, "_Z6squarePfS_", cudaFrame.FunctionName.String())
297296
assert.Equal(t, libpf.AddressOrLineno(0), cudaFrame.AddressOrLineno)
298297
}
299298

@@ -344,7 +343,7 @@ func TestCachedTemplateWithDifferentCorrelationIDs(t *testing.T) {
344343
assert.Equal(t, libpf.AddressOrLineno(0), cudaFrame.AddressOrLineno,
345344
"correlation ID must not leak into output")
346345
// Verify each launch got its own kernel name.
347-
assert.Contains(t, cudaFrame.FunctionName.String(), tc.kernelName[3:10],
346+
assert.Equal(t, tc.kernelName, cudaFrame.FunctionName.String(),
348347
"each launch should get its own kernel name")
349348
}
350349
}
@@ -382,7 +381,7 @@ func TestCUDAFrameIdxNonZero(t *testing.T) {
382381
// The CUDA frame at index 2 should have the kernel name.
383382
cudaFrame := outputs[0].Trace.Frames[2].Value()
384383
assert.Equal(t, libpf.CUDAKernelFrame, cudaFrame.Type)
385-
assert.Contains(t, cudaFrame.FunctionName.String(), "test")
384+
assert.Equal(t, "_Z4testv", cudaFrame.FunctionName.String())
386385

387386
// The non-CUDA frames should be untouched.
388387
for _, idx := range []int{0, 1, 3, 4} {

0 commit comments

Comments
 (0)