Skip to content

Commit 218ea00

Browse files
committed
Set default buffer pages appropriate for page size
The 1024 default for `--perf-buffer-size` and `--blob-perf-buffer-size` assumes a 4KB page size to give 4MB of contiguous memory per perfbuffer. But Arm and Powerpc architectures can have page sizes of 64KB and that could require a lot of memory on servers with many cores as perfbuffers are per cpu. Fix by calculating the defaults to give 4MB per perfbuffer.
1 parent 6b02964 commit 218ea00

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

cmd/tracee/cmd/root.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,11 @@ func initCmd() error {
172172

173173
// Buffer/Cache flags
174174

175+
defaultBufferPages := (4096 * 1024) / os.Getpagesize() // 4 MB of contiguous pages
175176
rootCmd.Flags().IntP(
176177
"perf-buffer-size",
177178
"b",
178-
1024, // 4 MB of contiguous pages
179+
defaultBufferPages,
179180
"<size>\t\t\t\tSize, in pages, of the internal perf ring buffer used to submit events from the kernel",
180181
)
181182
err = viper.BindPFlag("perf-buffer-size", rootCmd.Flags().Lookup("perf-buffer-size"))
@@ -185,7 +186,7 @@ func initCmd() error {
185186

186187
rootCmd.Flags().Int(
187188
"blob-perf-buffer-size",
188-
1024, // 4 MB of contiguous pages
189+
defaultBufferPages,
189190
"<size>\t\t\t\tSize, in pages, of the internal perf ring buffer used to send blobs from the kernel",
190191
)
191192
err = viper.BindPFlag("blob-perf-buffer-size", rootCmd.Flags().Lookup("blob-perf-buffer-size"))

tests/integration/tracee.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
"os"
78
"path/filepath"
89
"strconv"
910
"sync"
@@ -94,8 +95,9 @@ func startTracee(ctx context.Context, t *testing.T, cfg config.Config, output *c
9495

9596
cfg.Capture = capture
9697

97-
cfg.PerfBufferSize = 1024
98-
cfg.BlobPerfBufferSize = 1024
98+
defaultBufferPages := (4096 * 1024) / os.Getpagesize() // 4 MB of contiguous pages
99+
cfg.PerfBufferSize = defaultBufferPages
100+
cfg.BlobPerfBufferSize = defaultBufferPages
99101
cfg.PipelineChannelSize = 10000
100102

101103
// No process tree in the integration tests

0 commit comments

Comments
 (0)