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

fix: use ValidatedSetSelector to reduce memory usage in k8s client #317

Merged
merged 2 commits into from Nov 22, 2023

Conversation

loshz
Copy link
Contributor

@loshz loshz commented Nov 21, 2023

Which problem is this PR solving?

Short description of the changes

When looking through the documentation for the selector matching functionality, I noticed a comment about the underlying data being copied due to it being treated as potentially mutable.

We call the GetServiceForPod method of the cached k8s client at least twice per event when sending Honeycomb events and when creating spans in the OTEL handler. This means the same label selector values for both source and destination events are being copied a total of 4 times.

This PR updates the usage of the cache to use a ValidatedSetSelector which implements a Matches method that does not copy.

How to verify that this has the expected result

If possible, we should run a debug build in a testing environment and compare the total RAM usage to the figures shown in the graph attached to the original issue.

Signed-off-by: Dan Bond <danbond@protonmail.com>
Signed-off-by: Dan Bond <danbond@protonmail.com>
@loshz loshz requested a review from a team as a code owner November 21, 2023 23:28
@loshz loshz changed the title Validated label selector fix: use ValidatedSetSelector to reduce memory usage in k8s client Nov 21, 2023
Copy link
Contributor

@MikeGoldsmith MikeGoldsmith left a comment

Choose a reason for hiding this comment

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

Looks great, I'm happy to take this change and roll a new release so we can test with a new version.

@MikeGoldsmith MikeGoldsmith merged commit 529c18a into honeycombio:main Nov 22, 2023
5 of 6 checks passed
@loshz loshz deleted the validated-label-selector branch November 22, 2023 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[perf] High amount of in-memory bytes are created looking up k8s metadata
2 participants