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

Optimize CatalogSource controller memory consumption #11

Closed
everettraven opened this issue Mar 27, 2023 · 6 comments
Closed

Optimize CatalogSource controller memory consumption #11

everettraven opened this issue Mar 27, 2023 · 6 comments

Comments

@everettraven
Copy link
Collaborator

Based on the initial findings from #3 we noticed that there is a fairly large and persistent memory consumption increase (~232Mi) in the CatalogSource controller after reconciling a CatalogSource CR and creating the children Package and BundleMetadata CRs.

This increase in memory consumption is likely caused by the CatalogSource controller caching these child resources (which there can be a large number of). We should explore methods we can use to decrease the memory consumption to prevent the CatalogSource controller from hogging large amounts of memory.

Additional Context:

@anik120
Copy link
Collaborator

anik120 commented Mar 28, 2023

I asked chapGPT about this :)

How can I introduce a CustomResourceDefinition without the controller's informer caching the CustomResources

To introduce a CustomResourceDefinition (CRD) without the controller's informer caching the CustomResources, you can set the spec.preserveUnknownFields field of the CRD to true.

When spec.preserveUnknownFields is set to true, the informer won't cache the CustomResources since it doesn't know the schema of the CustomResource's fields. This can be useful in scenarios where you want to introduce a new CRD, but you don't want to update the controller's code to handle the new schema of the CustomResource.

To set spec.preserveUnknownFields to true, you can include the following YAML snippet in your CRD manifest:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: example.mydomain.com
spec:
  group: mydomain.com
  version: v1alpha1
  names:
    kind: Example
    plural: examples
  scope: Namespaced
  preserveUnknownFields: true
  # ...

Once you apply this manifest, the controller's informer won't cache the CustomResources of the Example kind, and it will treat them as unstructured data. You can still interact with the CustomResources using the Kubernetes API, but you may need to handle the CustomResources' fields manually in your controller's code.

@anik120
Copy link
Collaborator

anik120 commented Mar 28, 2023

☝🏽 that fits in the fbc as an api @joelanford is talking about too

@everettraven
Copy link
Collaborator Author

For some additional information, a discussion started in slack under this thread. The original thread was for an unrelated PR, but lead to a discussion about memory option around this comment

@joelanford
Copy link
Member

Related memory issue here: #22

@everettraven
Copy link
Collaborator Author

I think this is done, but it would probably be worth running through and evaluating this again and updating the pprof/README.md file to contain more up to date stats

@everettraven
Copy link
Collaborator Author

There have been quite a few changes since this issue was opened and would likely require another analysis of memory consumption prior to being able to make any optimizations. I'm going to close this as "obsolete" for now, but if folks feel this has been closed incorrectly please feel free to comment tagging me to reopen

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

No branches or pull requests

3 participants