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 |
jbudz
left a comment
There was a problem hiding this comment.
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.
Maybe we shouldn't pass the default values?
There was a problem hiding this comment.
This was like that in the previous implementation.
The getSummaryStatus is used in a couple of places:
status_serviceuses 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.
question: maybe we should iterate through toCheck set?
There was a problem hiding this comment.
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
…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
Attempt to solve #128061
The idea is to rewrite the
src/core/server/status/plugins_status.tslogic 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.PluginsStatusServiceclass 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.PluginsStatusServicethen signals the internalSubjectsthat are connected to the output observables.Key changes to reduce heap size and improve performance
switchMapandconcatMapoperators create new Observables with each higher order emission.Memory consumption impact
Heap size after Kibana started reduced from


800Mbto280Mb.Heap snapshot is taken right after Kibana started.
mainbranchthe current branch.