-
Notifications
You must be signed in to change notification settings - Fork 204
Store AST directly in provider mappings #6114
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
Conversation
|
Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
3c62d14 to
8cd14c8
Compare
|
/test |
8cd14c8 to
6860e91
Compare
|
| func (a *AST) Equal(other *AST) bool { | ||
| if a.root == nil || other.root == nil { | ||
| return a.root == other.root | ||
| } |
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.
nit 🙂
| } | |
| } | |
| // nil check above is mandatory as calling Hash() on a nil may cause a panic |
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.
This code change LGTM. the CI failures are due to TestOtelAPMIngestion (#4148) and TestRpmFleetUpgrade. The last one fails because it doesn't download in time the elastic-agent-8.17.0-SNAPSHOT-x86_64.rpm artifact with a context deadline exceeded (code ref)
cc @ycombinator should we create an issue about the latter?
I'm not seeing these tests failing on |
blakerouse
left a comment
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.
This is a great performance improvement! Nicely done.
* Store AST directly in dynamic provider mappings * Store AST directly in context provider mappings (cherry picked from commit fe0f6b0)
* Store AST directly in dynamic provider mappings * Store AST directly in context provider mappings (cherry picked from commit fe0f6b0)
* Store AST directly in dynamic provider mappings * Store AST directly in context provider mappings (cherry picked from commit fe0f6b0) # Conflicts: # internal/pkg/composable/controller.go
* Store AST directly in dynamic provider mappings * Store AST directly in context provider mappings (cherry picked from commit fe0f6b0) # Conflicts: # internal/pkg/composable/controller.go
(cherry picked from commit fe0f6b0) # Conflicts: # internal/pkg/composable/controller.go # Conflicts: # internal/pkg/composable/controller.go
We only signal from providers if the emitted data is different from the current state. This caused a bug where the data wasn't ever emitted if it was empty. The provider controller now distinguishes between no data (yet) and empty data. As a result, it's again possible to effectively disable all providers by using a local provider with no data. This is a regression caused by #6114. It doesn't apply to the main and 8.x branches due to #6169 refactoring provider initialisation in those.
We only signal from providers if the emitted data is different from the current state. This caused a bug where the data wasn't ever emitted if it was empty. The provider controller now distinguishes between no data (yet) and empty data. As a result, it's again possible to effectively disable all providers by using a local provider with no data. This is a regression caused by #6114. It doesn't apply to the main and 8.x branches due to #6169 refactoring provider initialisation in those.
We only signal from providers if the emitted data is different from the current state. This caused a bug where the data wasn't ever emitted if it was empty. The provider controller now distinguishes between no data (yet) and empty data. As a result, it's again possible to effectively disable all providers by using a local provider with no data. This is a regression caused by #6114. It doesn't apply to the main and 8.x branches due to #6169 refactoring provider initialisation in those. (cherry picked from commit 8ea9439)
We only signal from providers if the emitted data is different from the current state. This caused a bug where the data wasn't ever emitted if it was empty. The provider controller now distinguishes between no data (yet) and empty data. As a result, it's again possible to effectively disable all providers by using a local provider with no data. This is a regression caused by #6114. It doesn't apply to the main and 8.x branches due to #6169 refactoring provider initialisation in those. (cherry picked from commit 8ea9439) Co-authored-by: Mikołaj Świątek <mail@mikolajswiatek.com>




What does this PR do?
For all variable provider types, we store mappings as untyped dictionaries and only convert them to AST when we're about to generate actual vars. This means we have to recompute all of it every time there's a change to any of the provider data, even if all the other data is unaffected. For example, if a Kubernetes Pod gains a new label, we need to regenerate vars for all Pods.
Instead, we can store mappings as AST to begin with. Then the only cost of emitting new vars after a change is updating a bunch of references.
Why is it important?
This unnecessary recomputation can be quite expensive when there's a lot of mappings from the dynamic provider. See the benchstat report below:
Checklist
Related issues