-
Notifications
You must be signed in to change notification settings - Fork 76
Migrate from cgroup profiling to system-wide profiling #627
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
This also allows us to have multiple profilers in the future Signed-off-by: Francisco Javier Honduvilla Coto <[email protected]>
Temporarily comments out UI code that should be dealt with later
15949e5
to
2f041d5
Compare
2f041d5
to
40eb5f9
Compare
Fix web tests |
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.
Woah. Amazing!! 💯
Could you please open issues for all these? Note to the releaser: These should be mentioned in the release notes. |
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.
Looking good. I did the first round, and I'll continue to review this later on.
Especially, I haven't checked pkg/profiler/cpu.go
yet.
Awesome work so far 💯
This commit changes the array of groups to a single group, as this is the interface that the kubernetes discovery mechanism uses, and removes the systemd discoverer as it's no longer needed. All cgroups and system units in the box should be profiled automatically. If there's additional metadata, it will be added (see commit above). Signed-off-by: Francisco Javier Honduvilla Coto <[email protected]>
6de5176
to
d298e12
Compare
Just a couple of nits and then we can handle the rest in subsequent PRs |
Signed-off-by: Francisco Javier Honduvilla Coto <[email protected]>
Signed-off-by: Francisco Javier Honduvilla Coto <[email protected]>
Signed-off-by: Francisco Javier Honduvilla Coto <[email protected]>
d298e12
to
2228657
Compare
Address feedback |
This PR reworks how we attach the CPU profiler to create one global perf event, instead of creating one per cgroup. This has several advantages, including:
NewCgroupProfiler
s instances linearly use memory and CPU, as well as kernel space (fewer data structures that the kernel needs to create, fewer events that have to be delivered, etc)Design
The discovery mechanism (Kubernetes or Systemd) no longer drives the creation cgroup profilers, instead:
Changes vs the initial proposal
Cgroup filtering
One of the initial goals of this work was to keep compatibility with the current filtering that Parca Agent has. For example, adding a new flag to enable system-wide collection (
--system-wide
, for example) and otherwise we would collect profiles for the Kubernetes clusters or Cgroups that are discovered or specified via arguments.However, this proved to be trickier than I anticipated, due to the fact that the
bpf_get_current_cgroup_id()
helper used to retrieve the Cgroup id in BPF does not work under cgroups v1, which is widely used in Kubernetes environments. While a migration to cgroups v2 is on the way, we definitely want to support both cgroup versions.While this approach would have been the most efficient way to faithfully replicate the current behaviour, as we could do the filtering in BPF and avoid counting these stacks, as well as reading it in userspace, I tried fetching the Cgroup ID in userspace and do the filtering there. However, after trying out this idea, I was not able to read a cgroups v1 ID (one of the approaches).
In the end, I think that while the idea of trying to replicate the current behaviour (and in the future enable system-wide profile collection by default) has some validity, I am not sure if it's worth it. Not only this would be something temporary, but having to do the cgroup ID filtering in userspace will still generate more data and make us read the same data that we would have to do with system-wide enabled by default (minus the profile generation itself). Finding the correct paths for the cgroups can be difficult, too, which might bring bugs and will force us to do way more testing.
Profile generation
Initially, we proposed to generate a profile per cgroup to maintain the current behaviour and to allow filtering by cgroup (see point above).
In this PR we generate one profile per PID.
Other significant changes
Future work
Test plan
Bare metal
Minikube
Web UI

Fixes #260