-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: optimize activation of bundles with no inter-bundle path overlap #7155
base: main
Are you sure you want to change the base?
perf: optimize activation of bundles with no inter-bundle path overlap #7155
Conversation
ast/compile.go
Outdated
// WithPathConflictsCheckRoot enables checking path conflicts from the specified root instead | ||
// of the top root node. This would enable optimizting path conflict checks during bundle | ||
// activation if a bundle already defines its own root paths. | ||
func (c *Compiler) WithPathConflictsCheckRoot(rootPaths []string) *Compiler { |
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.
Any reason to use singular "root" for the name while the args and the property says "roots"?
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.
Good catch! Will change to use the plural form.
Signed-off-by: Shiqi Yang <[email protected]>
Signed-off-by: Ashutosh Narkar <[email protected]>
Signed-off-by: Ashutosh Narkar <[email protected]>
…-policy-agent#7153) Fixes open-policy-agent#7151 Signed-off-by: Anders Eknert <[email protected]>
Signed-off-by: Peter Macdonald <[email protected]>
Signed-off-by: Shiqi Yang <[email protected]>
Signed-off-by: Shiqi Yang <[email protected]>
Signed-off-by: Shiqi Yang <[email protected]>
179ecc8
to
5cd286b
Compare
Force pushing to sign off my commits... |
Signed-off-by: Shiqi Yang <[email protected]>
Why the changes in this PR are needed?
When multiple bundles are loaded into OPA using the bundle plugin, it takes a long time to active the bundles according to the logs. Profiling results has shown that most of the activation time is spent in checking path conflicts.
This PR avoids unnecessary path conflict checking when no root overlaps are guaranteed. This will reduce the number of expensive deep copies and hence improve bundle activation time and CPU utilization.
Resolves #7144.
What are the changes in this PR?
If a bundle has a manifest file with
roots
defined, then during path conflict checking, only check the sub-AST from the root path instead of the entire AST.Notes to assist PR review:
#7144 includes a detailed explanation and context on this change.
Further comments:
I wasn't able to find a good way of directly testing the change (i.e. testing that only subtree was checked when roots are defined in the manifest). Instead, I added some bundle plugin tests with different scenarios to make sure conflicts are correctly checked still.
Ideas on how to directly test this approach are welcome :)