Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ebpf: increase number of stack delta buckets #231

Merged
merged 4 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions processmanager/ebpf/ebpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ var outerMapsName = [...]string{
"exe_id_to_19_stack_deltas",
"exe_id_to_20_stack_deltas",
"exe_id_to_21_stack_deltas",
"exe_id_to_22_stack_deltas",
"exe_id_to_23_stack_deltas",
}

// Compile time check to make sure ebpfMapsImpl satisfies the interface .
Expand Down
11 changes: 5 additions & 6 deletions processmanager/ebpf/ebpf_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build !integration
// +build !integration

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

Expand All @@ -12,6 +9,7 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/ebpf-profiler/support"
)

func TestMapID(t *testing.T) {
Expand All @@ -26,18 +24,19 @@ func TestMapID(t *testing.T) {
0x3FF: 10, // 1023
0x400: 11, // 1024
0xFFFFF: 20, // 1048575 (2^20 - 1)
(1 << support.StackDeltaBucketLargest) - 1: support.StackDeltaBucketLargest,
}
for numStackDeltas, expectedShift := range testCases {
numStackDeltas := numStackDeltas
expectedShift := expectedShift
t.Run(fmt.Sprintf("deltas %d", numStackDeltas), func(t *testing.T) {
shift, err := getMapID(numStackDeltas)
require.NoError(t, err)
assert.Equal(t, expectedShift, shift,
fmt.Sprintf("wrong map name for %d deltas", numStackDeltas))
assert.Equal(t, expectedShift, shift, "wrong map name for %d deltas",
numStackDeltas)
})
florianl marked this conversation as resolved.
Show resolved Hide resolved
}

_, err := getMapID(1 << 22)
_, err := getMapID(1 << (support.StackDeltaBucketLargest + 1))
require.Error(t, err)
}
2 changes: 2 additions & 0 deletions support/ebpf/extmaps.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ extern bpf_map_def exe_id_to_18_stack_deltas;
extern bpf_map_def exe_id_to_19_stack_deltas;
extern bpf_map_def exe_id_to_20_stack_deltas;
extern bpf_map_def exe_id_to_21_stack_deltas;
extern bpf_map_def exe_id_to_22_stack_deltas;
extern bpf_map_def exe_id_to_23_stack_deltas;
extern bpf_map_def hotspot_procs;
extern bpf_map_def kernel_stackmap;
extern bpf_map_def dotnet_procs;
Expand Down
4 changes: 4 additions & 0 deletions support/ebpf/native_stack_trace.ebpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ STACK_DELTA_BUCKET(18);
STACK_DELTA_BUCKET(19);
STACK_DELTA_BUCKET(20);
STACK_DELTA_BUCKET(21);
STACK_DELTA_BUCKET(22);
STACK_DELTA_BUCKET(23);

// Unwind info value for invalid stack delta
#define STACK_DELTA_INVALID (STACK_DELTA_COMMAND_FLAG | UNWIND_COMMAND_INVALID)
Expand Down Expand Up @@ -154,6 +156,8 @@ void *get_stack_delta_map(int mapID) {
case 19: return &exe_id_to_19_stack_deltas;
case 20: return &exe_id_to_20_stack_deltas;
case 21: return &exe_id_to_21_stack_deltas;
case 22: return &exe_id_to_22_stack_deltas;
case 23: return &exe_id_to_23_stack_deltas;
default: return NULL;
}
}
Expand Down
Binary file modified support/ebpf/tracer.ebpf.release.amd64
Binary file not shown.
Binary file modified support/ebpf/tracer.ebpf.release.arm64
Binary file not shown.
4 changes: 2 additions & 2 deletions support/ebpf/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,8 @@ void decode_bias_and_unwind_program(u64 bias_and_unwind_program, u64* bias, int*

// Smallest stack delta bucket that holds up to 2^8 entries
#define STACK_DELTA_BUCKET_SMALLEST 8
// Largest stack delta bucket that holds up to 2^21 entries
#define STACK_DELTA_BUCKET_LARGEST 21
// Largest stack delta bucket that holds up to 2^23 entries
#define STACK_DELTA_BUCKET_LARGEST 23

// Struct of the `system_config` map. Contains various configuration variables
// determined and set by the host agent.
Expand Down
3 changes: 2 additions & 1 deletion tools/coredump/ebpfhelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ func __bpf_map_lookup_elem(id C.u64, mapdef *C.bpf_map_def, keyptr unsafe.Pointe
&C.exe_id_to_11_stack_deltas, &C.exe_id_to_12_stack_deltas, &C.exe_id_to_13_stack_deltas,
&C.exe_id_to_14_stack_deltas, &C.exe_id_to_15_stack_deltas, &C.exe_id_to_16_stack_deltas,
&C.exe_id_to_17_stack_deltas, &C.exe_id_to_18_stack_deltas, &C.exe_id_to_19_stack_deltas,
&C.exe_id_to_20_stack_deltas, &C.exe_id_to_21_stack_deltas:
&C.exe_id_to_20_stack_deltas, &C.exe_id_to_21_stack_deltas, &C.exe_id_to_22_stack_deltas,
&C.exe_id_to_23_stack_deltas:
ctx.stackDeltaFileID = *(*C.u64)(keyptr)
return unsafe.Pointer(stackDeltaInnerMap)
case &C.unwind_info_array:
Expand Down