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

perf: Remove with statement to avoid deepcopying data.inventory #252

Merged

Conversation

maxsmythe
Copy link
Contributor

This is a possible fix for open-policy-agent/gatekeeper#2283

Digging through the OPA code, the with statement triggers a deepcopy of the referenced data. With the new execution model implemented for performance improvements, this deepcopy would be run multiple times, which could mean significant CPU overhead and unnecessary memory usage.

Not using the with key would make it harder to mask out only resources in specific namespaces if we ever create namespace-scoped constraint templates, but should not hurt near-term functionality.

It may be we will need an alternative method for accessing the data cache if we need to mask visibility in the future.

Signed-off-by: Max Smythe smythe@google.com

Signed-off-by: Max Smythe <smythe@google.com>
@codecov-commenter
Copy link

Codecov Report

Base: 50.30% // Head: 50.30% // No change to project coverage 👍

Coverage data is based on head (690a2c5) compared to base (1ed2724).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #252   +/-   ##
=======================================
  Coverage   50.30%   50.30%           
=======================================
  Files          64       64           
  Lines        4266     4266           
=======================================
  Hits         2146     2146           
  Misses       1881     1881           
  Partials      239      239           
Flag Coverage Δ
unittests 50.30% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...eworks/constraint/pkg/client/drivers/local/rego.go 60.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@maxsmythe
Copy link
Contributor Author

@ritazh @sozercan We ran the numbers for gator test and this appears to eliminate the caching penalty that open-policy-agent/gatekeeper#2301 was intended to address. I think this PR will benefit open-policy-agent/gatekeeper#2256

Copy link
Member

@sozercan sozercan left a comment

Choose a reason for hiding this comment

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

LGTM

@maxsmythe maxsmythe merged commit a3d297b into open-policy-agent:master Oct 6, 2022
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.

None yet

4 participants