-
Notifications
You must be signed in to change notification settings - Fork 442
tetragon: Add bench application #261
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
Conversation
1730ea3
to
c4394ab
Compare
pkg/bench/bench.go
Outdated
|
||
if _, err := os.Stat(option.Config.HubbleLib); err != nil { | ||
// Running outside the source tree, fall back to default location. | ||
option.Config.HubbleLib = "/var/lib/hubble-fgs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, will use that one, thanks
) | ||
|
||
func EnableBpfStats() { | ||
err := os.WriteFile("/proc/sys/kernel/bpf_stats_enabled", []byte("1"), 0666) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the perm mode ok? maybe restrict it a bit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that permission will be used only if the file does not exist and needs to be created, so we are fine here
pkg/bench/cpuusage.go
Outdated
func CPUUsageFromCPUAcct(containerID string) CPUUsage { | ||
|
||
rss := int64(0) | ||
memStatFilename := fmt.Sprintf("/sys/fs/cgroup/memory/docker/%s/memory.stat", containerID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this seems cgroupv1 hierarchy, I assume that this could also run in cgroupv2 the path would be /sys/fs/cgroup/$path/%s/memory.stat
in that case where $path does not container the 'memory' directory or controller as it is unified.
You could use this new helper:
https://github.com/cilium/tetragon/blob/main/pkg/cgroups/cgroups.go#L567 if it returns CGROUP_UNIFIED
then you are in pure cgroupv2 and you have to fix that path without 'memory' directory, for everything else you can assume cgroupv1 that is the one that is used to track resources. Hybrid cgroupv2 is only used to organize processes together but resources tracking at cgroupv1.
It would be cool if we can standardize on those ;-) !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw where this is called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The full cgroup path may not container docker directory at all or another container runtime, I'm missing context, but if you could read /proc/self/cgroups and adapt according to cgroup version and the controllers you are interested in to get right working paths without hardcoding it here. There is some logic in that cgroups.go package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, I'll remove it for now, because it's not used and check on that more, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Some minor requests / suggestions.
Leftover changes from 'make generate'. Signed-off-by: Jiri Olsa <[email protected]>
Adding summary object to carry all the measured data and doing the results output. Signed-off-by: Jiri Olsa <[email protected]>
Adding base of the bench package, that allows to run observer with custom configuration and provides generic arguments. Signed-off-by: Jiri Olsa <[email protected]>
Adding interface to quesry bpfstats data from bpf programs. Signed-off-by: Jiri Olsa <[email protected]>
Adding util object that carries some other helper objects. Signed-off-by: Jiri Olsa <[email protected]>
Adding tetragon-bench application to meassure tracing workloads. It runs benchmark specified with -trace option. At the moment there is no benchmark defined, they are coming in following changes. Signed-off-by: Jiri Olsa <[email protected]>
Adding benchmark that does many read and writes in multiple threads and monitors all this data in tetragon. Could be run with: # ./tetragon-bench -trace rw And configured with extra options: -bench-rw-count uint bench rw read/write count (default 100) -bench-rw-loops uint bench rw number of loops (default 100) -bench-rw-size uint bench rw buffer size (default 1024) -bench-rw-threads uint bench rw number of threads (default 4) -bench-rw-sleep uint bench rw sleep in ms (default 1) Signed-off-by: Jiri Olsa <[email protected]>
Adding benchmark that does many failed open syscalls and monitors them in tetragon. Could be run with: # ./tetragon-bench -trace open And configured with extra options: -bench-open-loops uint bench open number of loops (default 1000000) -bench-open-sleep uint bench open sleep between open syscalls (us) (default 1) -bench-open-threads uint bench open number of threads (default 4) Signed-off-by: Jiri Olsa <[email protected]>
Allows to run custom benchmark with specific crd file, like: # ./tetragon-bench -crd crds/examples/names.yaml -- perf bench sched pipe Or with perf sampling: # perf record -g -e cycles:k ./tetragon-bench -crd ./read_write.yaml -json-encode -- perf bench sched pipe Arguments after '--' will be executed as workload. When workload is finished the bench will exit. Signed-off-by: Jiri Olsa <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Adding benchmark application to measure tracing workloads.
The tetragon-bench application starts tetragon (or not for -baseline option)
for given CRD file and runs workload.
At the end it displays some stats, like:
It's possible to run predefined workloads with builtin CRD files,
or run specific custom benchmark.
The predefined benchmarks are rw and open and can be run with:
They do and monitor some simple read/write open operations and they are there
mainly to show the possibility of builtin benchmark if we think it's good idea ;-)
The custom benchmark is what I'm using most at the moment and
it allows to pass CRD file to start tetragon with and specify workload, like:
I'm doing perf profiles to check on CRD stuff with:
Signed-off-by: Jiri Olsa [email protected]