-
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
Increase flatten performance of SearchSource #150658
Increase flatten performance of SearchSource #150658
Conversation
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
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.
Great! Thanks for improving the performance! 👏
|
||
const uniqueFieldNames = new Set(); | ||
const uniqueFields = []; | ||
for (const field of bodyFields.concat(filteredDocvalueFields)) { |
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.
We could also change to forEach
here instead of for
to minimize event loop blocking.
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.
thx, you mean?
bodyFields.concat(filteredDocvalueFields).forEach
right? wouldn't this also block the event loop?
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.
Right. Well, it will block in chunks but it might also allow some browser work in between. Or maybe I am just making this up 😀
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.
I think it would be the case if it was an async/await type of forEach, but here I think it's blocking the even loop until done (pls prove me wrong 😃 )
@elasticmachine merge upstream |
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Page load bundle
History
To update your PR or re-run it, just comment with: cc @kertal |
Summary
This PR improves the performance of flattening the requested fields of the search source data request. it replaces the use of lodash
uniqWith
with a different implementation reducing the amount of iteration, which improves performance a lot when there are many fields. So when I tested with a data view having about 10.000 fields the time used for this loop went from 130-150ms to 2.3-4.1 msHowever it's important to note that this it just improved when there are field filters in the data view set. Else the improved part of the code isn't hit.
Fixes #136854