[ML] Adds cache for data recognizer module configs to reduce number of privilege checks#126338
Conversation
|
Pinging @elastic/ml-ui (:ml) |
| private _resultsService: ReturnType<typeof resultsServiceProvider>; | ||
| private _calculateModelMemoryLimit: ReturnType<typeof calculateModelMemoryLimitProvider>; | ||
|
|
||
| private _configCache: Config[] | null = null; |
There was a problem hiding this comment.
Should we invalidate this cache if the saved object configs have been changed?
There was a problem hiding this comment.
As I mentioned in the description
The modules on disk and in the saved objects will not change in the time frame that each DataRecognizer instance exist.
Each instance of the DataRecognizer exists for one endpoint call. The modules on disk will not change in that time frame. The modules in the saved object could theoretically change if someone installs a fleet module at the exact same time, but IMO it is very unlikely.
The _has_privileges calls were all happening from inside the saved object client and so I imagine adding a check to see if the saved objects have changed each loop would reintroduce them.
There was a problem hiding this comment.
Suggestion: It would be great if we could add some of the PR description and this explanation as comments to the code so the reasoning is also documented there.
|
@elasticmachine merge upstream |
walterra
left a comment
There was a problem hiding this comment.
Code LGTM, did a local test and verified the improvement in APM compared to main . Just added a comment about potentially adding some comments to the code.
…dyelastic/kibana into adding-data-recognizer-config-cache
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: |
…ed-unexpectedly-error * 'main' of github.com:elastic/kibana: (46 commits) Fix copy and pasted renderer user_name test (elastic#126663) [Gauge] Vis editors gauge legacy percent mode. (elastic#126318) Remove all cases related code from timelines (elastic#127003) Hide Enterprise search panel when no nodes are present (elastic#127100) [Lens] Fixed flakiness on runtime fields' appearance on the list (elastic#126945) [Security Solution][Lists] - Add missing privileges callout to exception lists page (elastic#126874) [Security Solution][Lists] - Updates exception flyout edit error messages (elastic#126875) [Security Solution][Rules] - Remove rule selection for read only users (elastic#126827) Fix session cleanup test (elastic#126966) [ftr] implement support for accessing ES through CCS (elastic#126547) [type-summarizer] always use normalized paths, fix windows compat (elastic#127055) Revert "[ci] Configure hourly pipeline for a small spot instance trial (elastic#126824)" Revert "[CI] Expand spot instance trial a bit (elastic#126928)" [Alerting] Adding functional tests for alerting and actions telemetry (elastic#126528) [Telemetry] Check permissions when requesting telemetry (elastic#126238) Don't submit empty seed_urls or sitemap_urls when making a partial crawl request (elastic#126972) Remove License Requirement for Enterprise Search App Search Meta Engines (elastic#127046) [ML] Adding data recognizer module config cache (elastic#126338) skip flaky suite (elastic#126027) [Reporting] Improve error logging for rescheduled jobs (elastic#126737) ... # Conflicts: # x-pack/plugins/reporting/server/core.ts # x-pack/plugins/reporting/server/lib/tasks/execute_report.ts
…re-browser-errors * 'main' of github.com:elastic/kibana: (46 commits) Fix copy and pasted renderer user_name test (elastic#126663) [Gauge] Vis editors gauge legacy percent mode. (elastic#126318) Remove all cases related code from timelines (elastic#127003) Hide Enterprise search panel when no nodes are present (elastic#127100) [Lens] Fixed flakiness on runtime fields' appearance on the list (elastic#126945) [Security Solution][Lists] - Add missing privileges callout to exception lists page (elastic#126874) [Security Solution][Lists] - Updates exception flyout edit error messages (elastic#126875) [Security Solution][Rules] - Remove rule selection for read only users (elastic#126827) Fix session cleanup test (elastic#126966) [ftr] implement support for accessing ES through CCS (elastic#126547) [type-summarizer] always use normalized paths, fix windows compat (elastic#127055) Revert "[ci] Configure hourly pipeline for a small spot instance trial (elastic#126824)" Revert "[CI] Expand spot instance trial a bit (elastic#126928)" [Alerting] Adding functional tests for alerting and actions telemetry (elastic#126528) [Telemetry] Check permissions when requesting telemetry (elastic#126238) Don't submit empty seed_urls or sitemap_urls when making a partial crawl request (elastic#126972) Remove License Requirement for Enterprise Search App Search Meta Engines (elastic#127046) [ML] Adding data recognizer module config cache (elastic#126338) skip flaky suite (elastic#126027) [Reporting] Improve error logging for rescheduled jobs (elastic#126737) ... # Conflicts: # x-pack/plugins/reporting/server/lib/tasks/execute_report.ts
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Adding a cache for modules loaded from disk and from the saved objects index.
The modules on disk and in the saved objects will not change in the time frame that each
DataRecognizerinstance exist.By retrieving the modules from a cache for subsequent calls to
_loadConfigs, the total number privileges checks caused by the saved object loading is drastically reduced.vs
Fixes #125913
Unit or functional tests were updated or added to match the most common scenarios
This was checked for breaking API changes and was labeled appropriately