-
Notifications
You must be signed in to change notification settings - Fork 8.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
Rewrite plugin_status logic limiting usage of Observables (reducing heap size) #128324
Rewrite plugin_status logic limiting usage of Observables (reducing heap size) #128324
Conversation
buildkite build this |
buildkite test this |
@gsoldevila, if we confirm the positive impact of the PR on memory consumption, I'd consider porting it back to |
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 huge, memory consumption looks great:
#128061 (comment) for comparison.
this.coreStatus = coreStatus!; | ||
// console.log('⚡ CORE STATUS! elastic: ', coreStatus.elasticsearch.level.toString(), '; savedObjects: ', coreStatus.savedObjects.level.toString()); | ||
const derivedStatus = getSummaryStatus(Object.entries(this.coreStatus), { | ||
allAvailableSummary: `All dependencies are available`, |
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.
Maybe we shouldn't pass the default values?
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 was like that in the previous implementation.
The getSummaryStatus
is used in a couple of places:
status_service
uses the default"All services are available"
plugins_status
(this class) uses the slightly different"All dependencies are available"
.
The problem is that getSummaryStatus
method does not currently have the knowledge of whether it's being called with plugins statuses only, or with plugins statuses + core services statuses.
But if we agree to use the exact same message for both cases, then I can probably remove that default value.
|
||
private updatePluginsStatuses(plugins: PluginName[]): void { | ||
const toCheck = new Set<PluginName>(plugins); | ||
for (let i = 0; i < this.orderedPluginNames.length && toCheck.size > 0; ++i) { |
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.
question: maybe we should iterate through toCheck
set?
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.
Actually, we need to iterate in "depth" order:
- first updating root plugins' statuses, then updating
depth=2
, and so on so forth.
Otherwise we might try to update a plugin status before updating its dependencies.
Pinging @elastic/kibana-core (Team:Core) |
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: |
…eap size) (elastic#128324) * WIP * Fix behavior when no plugins are defined * Remove unused import, reduce debounce times * Fix startup behavior * Misc improvements following PR comments * Fix plugin_status UTs * Code cleanup + enhancements * Remove fixed FIXME (cherry picked from commit a645545)
…ucing heap size) (#128324) (#129507) * Rewrite plugin_status logic limiting usage of Observables (reducing heap size) (#128324) * WIP * Fix behavior when no plugins are defined * Remove unused import, reduce debounce times * Fix startup behavior * Misc improvements following PR comments * Fix plugin_status UTs * Code cleanup + enhancements * Remove fixed FIXME (cherry picked from commit a645545) * Add extra tests from #128769 * Fix linting issues (older typescript version?) * Fix TS version issues
Attempt to solve #128061
The idea is to rewrite the
src/core/server/status/plugins_status.ts
logic in order to simplify the RxJS pipeline. We take into account "input" observables and "output" observables, but we no longer use RxJS for the internal update of plugin statuses.PluginsStatusService
class maintains an updated copy of the state, in a sort of Redux store pattern, so to speak. The state includes convenient structures to make updates more efficient. These structures include a tree of reverse dependencies, and a list of plugin names sorted by depth. The root plugins (depth = 1) are those that do not depend on any other plugin. A plugin that depends on a root plugin will have depth = 2, and so on so forth.PluginsStatusService
then signals the internalSubjects
that are connected to the output observables.Key changes to reduce heap size and improve performance
switchMap
andconcatMap
operators create new Observables with each higher order emission.Memory consumption impact
Heap size after Kibana started reduced from
800Mb
to280Mb
.Heap snapshot is taken right after Kibana started.
main
branchthe current branch.