-
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
Fix multi terms performance bottleneck #126575
Conversation
Pinging @elastic/kibana-vis-editors @elastic/kibana-vis-editors-external (Team:VisEditors) |
Pinging @elastic/kibana-app-services (Team:AppServicesSv) |
x-pack/plugins/lens/public/xy_visualization/color_assignment.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Marco Liberati <[email protected]>
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.
Code review 👍
Left just a minor nitpick comment.
Will test it locally now
const isCached = this.formatCache.has(fieldParams); | ||
const cachedFormat = | ||
this.formatCache.get(fieldParams) || | ||
getFieldFormat({ id: fieldParams.id, params: fieldParams }); | ||
if (!isCached) { | ||
this.formatCache.set(fieldParams, cachedFormat); | ||
} |
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: inverting the order will remove few lines
const isCached = this.formatCache.has(fieldParams); | |
const cachedFormat = | |
this.formatCache.get(fieldParams) || | |
getFieldFormat({ id: fieldParams.id, params: fieldParams }); | |
if (!isCached) { | |
this.formatCache.set(fieldParams, cachedFormat); | |
} | |
if (!this.formatCache.has(fieldParams);) { | |
this.formatCache.set( | |
fieldParams, | |
getFieldFormat({ id: fieldParams.id, params: fieldParams }) | |
); | |
} | |
return this.formatCache.get(fieldParams); |
💚 Build SucceededMetrics [docs]Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
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.
code LGTM
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.
Tested locally in Safari and cannot break it.
On the other note I could not reproduce the initial performance problem either while testing side by side with an instance from main
(cherry picked from commit 555ec91)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
(cherry picked from commit 555ec91) Co-authored-by: Joe Reuter <[email protected]>
This PR drastically reduces the number of times new formatter instances as constructed, speeding up rendering of chart with lots of data points especially if they are using multi terms (because it would instantiate new formatter instances for each part of the key from scratch on each formatting).
Before:

After:

There are a few other things to improve but those are to most relevant ones.