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

pkg/cgroups: Cache pod metadata on datapath events #32615

Merged
merged 3 commits into from
May 25, 2024

Conversation

aditighag
Copy link
Member

See commits description.

@aditighag aditighag requested a review from a team as a code owner May 17, 2024 23:46
@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label May 17, 2024
@aditighag aditighag mentioned this pull request May 17, 2024
1 task
@aditighag aditighag added the release-note/misc This PR makes changes that have no direct user impact. label May 17, 2024
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label May 17, 2024
@aditighag aditighag force-pushed the pr/aditighag/cache-cgroup-metadata branch 2 times, most recently from 5fdb0ae to d6b947f Compare May 17, 2024 23:52
Copy link
Member

@sayboras sayboras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@aditighag aditighag force-pushed the pr/aditighag/cache-cgroup-metadata branch from d6b947f to c5c4ec9 Compare May 21, 2024 23:37
@aditighag aditighag force-pushed the pr/aditighag/cache-cgroup-metadata branch from c5c4ec9 to da60744 Compare May 22, 2024 00:06
@aditighag
Copy link
Member Author

/ci-runtime

Copy link
Member

@joestringer joestringer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor further comments on the use of WaitGroups for synchronizing the unit tests - The usage doesn't seem to match canonical Go usage, and doesn't match up with the API comments in the library package. Fixing that up by passing it as a parameter or switching to channels should be a simple change though AFAICT.

pkg/cgroups/manager/manager.go Outdated Show resolved Hide resolved
pkg/cgroups/manager/manager.go Outdated Show resolved Hide resolved
pkg/cgroups/manager/manager.go Outdated Show resolved Hide resolved
The test case fails without the setup
when run by itself.

Fixes: 92ea5a1 ("pkg/cgroups: Replace gocheck with built-in go test")
Signed-off-by: Aditi Ghag <aditi@cilium.io>
Signed-off-by: Aditi Ghag <aditi@cilium.io>
@aditighag aditighag force-pushed the pr/aditighag/cache-cgroup-metadata branch from da60744 to b99accf Compare May 24, 2024 21:26
@aditighag
Copy link
Member Author

/ci-runtime

@aditighag aditighag removed the request for review from gentoo-root May 24, 2024 21:33
@aditighag aditighag force-pushed the pr/aditighag/cache-cgroup-metadata branch from b99accf to be4655d Compare May 24, 2024 21:49
@aditighag
Copy link
Member Author

/ci-runtime

Copy link
Member

@joestringer joestringer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This solution ended up even tidier than what I had in mind. Nice one 👍

pkg/cgroups/manager/manager.go Show resolved Hide resolved
Cgroup manager events were previously synchronized
via a channel. However, Hubble calls GetPodMetadataForContainer
on datapath socket tracing events that can be generated much more
frequently than control plane events.
Add a cache for the datapath read events in order to reduce the overhead
associated with channel events processing. This would mean that the
datapath events may get data via cache while any pod delete events
are in progress. Since only the control plane events are required to
be synchronized, it's acceptable that datapath tracing events may see
cached data for a short duration.

Benchmark results:

Before:
BenchmarkGetPodMetadataForContainer-14    	  848550	      1383 ns/op

After:
BenchmarkGetPodMetadataForContainer-14    	 2885898	       408.7 ns/op

Reported-by: Joe Stringer <joe@cilium.io>
Signed-off-by: Aditi Ghag <aditi@cilium.io>
@aditighag aditighag force-pushed the pr/aditighag/cache-cgroup-metadata branch from be4655d to c730e61 Compare May 24, 2024 23:11
@aditighag
Copy link
Member Author

/ci-runtime

@aditighag
Copy link
Member Author

/test

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label May 25, 2024
@aditighag aditighag added this pull request to the merge queue May 25, 2024
Merged via the queue into cilium:main with commit 71cb104 May 25, 2024
63 of 64 checks passed
@aditighag aditighag deleted the pr/aditighag/cache-cgroup-metadata branch May 25, 2024 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants