Skip to content
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

[Dev tools] Fix performance issue with autocomplete suggestions #143428

Merged

Conversation

mibragimov
Copy link
Contributor

@mibragimov mibragimov commented Oct 17, 2022

Closes #132495

Summary

This PR addresses the issue of the browser event loop being blocked for a long time when retrieving autocomplete suggestions with large responses. The proposed solution is to protect against large responses by limiting the response size to 10MB. This is done by reading the response stream and accumulating the data in chunks. If the accumulated data exceeds the limit, the stream is destroyed and an error is thrown. In case of an error, an empty object for the failed request and the rest of the successful requests are returned.

Testing

To ensure that the response size limit is working, you can change the RESPONSE_SIZE_LIMIT to 1 and run the following curl command:

curl -XGET 'http://localhost:5620/api/console/autocomplete_entities?indices=true&fields=true&templates=true&dataStreams=true'

You should see an empty object for each key in the response.

Change the response size limit to higher than the response size, and you should see the response with autocomplete suggestions.

Test with different values for the query parameters and verify that the response is as expected. e.g. indices=false should return an empty object for the aliases key.

Release note

This PR fixes the issue of retrieving autocomplete suggestions causing the UI to freeze. It also adds a couple of improvements to better handle the error cases and optimize the performance of the autocomplete suggestions.

@mibragimov mibragimov added Feature:Console Dev Tools Console Feature Feature:Dev Tools release_note:fix Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v8.6.0 labels Oct 17, 2022
@mibragimov mibragimov requested a review from alexwizp October 17, 2022 09:56
@mibragimov mibragimov self-assigned this Oct 17, 2022
@mibragimov mibragimov requested a review from sabarasaba October 19, 2022 10:07
Copy link
Member

@sabarasaba sabarasaba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

latest lgtm, tested locally and seems to work fine!

@mibragimov
Copy link
Contributor Author

@elasticmachine merge upstream

@mibragimov
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
console 26.8KB 26.7KB -150.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
console 36 35 -1

Total ESLint disabled count

id before after diff
console 39 38 -1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @mibragimov

@mibragimov mibragimov added the backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) label Oct 21, 2022
@mibragimov mibragimov marked this pull request as ready for review October 21, 2022 09:27
@mibragimov mibragimov requested a review from a team as a code owner October 21, 2022 09:27
@elasticmachine
Copy link
Contributor

Pinging @elastic/platform-deployment-management (Team:Deployment Management)

@mibragimov mibragimov merged commit 220f867 into elastic:main Oct 21, 2022
@mibragimov mibragimov deleted the console/autocomplete_performance_issue branch October 21, 2022 09:28
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Oct 21, 2022
…tic#143428)

* Fix performance issue with autocomplete suggestions

* Add unit tests for streamToString function

* Address CR change

Co-authored-by: Muhammad Ibragimov <muhammad.ibragimov@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 220f867)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.5

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Oct 21, 2022
) (#143813)

* Fix performance issue with autocomplete suggestions

* Add unit tests for streamToString function

* Address CR change

Co-authored-by: Muhammad Ibragimov <muhammad.ibragimov@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 220f867)

Co-authored-by: Muhammad Ibragimov <53621505+mibragimov@users.noreply.github.com>
jloleysens added a commit to jloleysens/kibana that referenced this pull request Oct 24, 2022
* main: (57 commits)
  [Files] Filepicker (elastic#143111)
  [Infrastructure UI] Replace Lens table with EUI table and own api (elastic#142871)
  [api-docs] Daily api_docs build (elastic#143829)
  [api-docs] Daily api_docs build (elastic#143825)
  [api-docs] Daily api_docs build (elastic#143823)
  [Security Solution] Restructuring folders of Detection Engine + refactoring Rule Management (elastic#142950)
  [Dev tools] Fix performance issue with autocomplete suggestions (elastic#143428)
  [Security Solution] Disable ML rule's edit button link under basic license (elastic#143260)
  [Lens]  Use the language-documentation package for formula (elastic#143649)
  [api-docs] Daily api_docs build (elastic#143811)
  [Security Solution] Fix missing title on inspect pop-up (elastic#143601)
  fix incorrect filters being passed to events table causing duplicate entries in our inpsect tool request tab (elastic#143239)
  [Security Solution][Endpoint] `get-file` response action kibana download file API (elastic#143708)
  Rely on refresh context to update stats independently of overview cards. (elastic#143308)
  [RAM] Rule event log - Fix incorrect results when filtering by message and outcome simultaneously (elastic#143119)
  [ML] Display link to create data view from error cases in data frame analytics results pages (elastic#143596)
  Update links in README :) (elastic#143675)
  Add more tests for ml_inference_logic (elastic#143764)
  skip failing test suite (elastic#143717)
  [DOCS] Add assignees to case APIs (elastic#143610)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Feature:Console Dev Tools Console Feature Feature:Dev Tools release_note:fix Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v8.5.0 v8.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Console] Address error cases, race conditions, and performance when retrieving autocomplete entities
6 participants