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

[Dataset Quality] Optimize bundle size and chunks fragmentation #194661

Merged
merged 3 commits into from
Oct 2, 2024

Conversation

tonyghiani
Copy link
Contributor

@tonyghiani tonyghiani commented Oct 2, 2024

📓 Summary

Closes #191602

This work reduces the initial bundle size for the dataset quality plugin by ~55% and reduces fragmentation in the chunks when the main page loads.

Before After
Screenshot 2024-10-02 at 09 56 35 Screenshot 2024-10-02 at 09 59 16
Screenshot 2024-10-02 at 09 56 55 Screenshot 2024-10-02 at 09 58 59

@tonyghiani tonyghiani added release_note:skip Skip the PR/issue when compiling release notes Team:obs-ux-logs Observability Logs User Experience Team labels Oct 2, 2024
Comment on lines -59 to -64
const Header = dynamic(() => import('./header'));
const Warnings = dynamic(() => import('./warnings/warnings'));
const EmptyStateWrapper = dynamic(() => import('./empty_state/empty_state'));
const Table = dynamic(() => import('./table/table'));
const Filters = dynamic(() => import('./filters/filters'));
const SummaryPanel = dynamic(() => import('./summary_panel/summary_panel'));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note

All of these chunks were loaded in parallel when loading the page, causing an excessive fragmentation for a UI that can loaded at once.

The lazy loading now happens for the main chunk on the index file, where the getter dynamically import the whole UI island.

Copy link
Contributor

Choose a reason for hiding this comment

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

to better understand what happened here:
Should we use this approach then only for elements in the UI that are showed after some interaction? for example a flyout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sort of, the best way to think about this is to split only when we might not need something.
For instance, in the above case we were splitting into 6 chunks sections of the same page that are always immediately loaded when the page is visited. In this case we could consider it as a single "UI island" that can be dynamically loaded at once, reducing the back and forth with the server.

The flyout example you are doing is a good one, as the user might never open the flyout during a session.

@tonyghiani tonyghiani marked this pull request as ready for review October 2, 2024 09:26
@tonyghiani tonyghiani requested a review from a team as a code owner October 2, 2024 09:26
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-logs-team (Team:obs-ux-logs)

@tonyghiani tonyghiani added the backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) label Oct 2, 2024
@botelastic botelastic bot added the ci:project-deploy-observability Create an Observability project label Oct 2, 2024
Copy link
Contributor

@yngrdyn yngrdyn left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for these changes 🚀

@kibana-ci
Copy link
Collaborator

kibana-ci commented Oct 2, 2024

💛 Build succeeded, but was flaky

  • Buildkite Build
  • Commit: fd31f49
  • Kibana Serverless Image: docker.elastic.co/kibana-ci/kibana-serverless:pr-194661-fd31f49289f6

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #12 / AllCasesSelectorModal Closing modal when pressing the x icon

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
datasetQuality 15 14 -1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
datasetQuality 208.0KB 219.2KB +11.2KB

Page load bundle

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

id before after diff
datasetQuality 49.7KB 18.4KB -31.2KB
Unknown metric groups

API count

id before after diff
datasetQuality 15 14 -1

async chunk count

id before after diff
datasetQuality 16 13 -3

History

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

@tonyghiani tonyghiani merged commit ce8c9d8 into elastic:main Oct 2, 2024
25 checks passed
@tonyghiani tonyghiani deleted the 191602-dataset-quality-bundle branch October 2, 2024 16:37
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/11147882123

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Oct 2, 2024
…tic#194661)

## 📓 Summary

Closes elastic#191602

This work reduces the initial bundle size for the dataset quality plugin
by **~55%** and reduces fragmentation in the chunks when the main page
loads.

| Before | After |
|--------|--------|
| <img width="525" alt="Screenshot 2024-10-02 at 09 56 35"
src="https://github.com/user-attachments/assets/06fec02c-ff2c-4771-981f-a761bda67eae">
| <img width="521" alt="Screenshot 2024-10-02 at 09 59 16"
src="https://github.com/user-attachments/assets/a243b09a-9d83-4d0d-b875-20855bb18f5d">
|
| <img width="1398" alt="Screenshot 2024-10-02 at 09 56 55"
src="https://github.com/user-attachments/assets/66d2c131-b0b7-47e1-9a9a-e1be57e69bbb">
| <img width="678" alt="Screenshot 2024-10-02 at 09 58 59"
src="https://github.com/user-attachments/assets/39e6515e-5a83-4d97-97c8-cce01b7c6887">
|

Co-authored-by: Marco Antonio Ghiani <[email protected]>
(cherry picked from commit ce8c9d8)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

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 2, 2024
…#194661) (#194746)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Dataset Quality] Optimize bundle size and chunks fragmentation
(#194661)](#194661)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Marco Antonio
Ghiani","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-02T16:37:04Z","message":"[Dataset
Quality] Optimize bundle size and chunks fragmentation (#194661)\n\n## 📓
Summary\r\n\r\nCloses #191602 \r\n\r\nThis work reduces the initial
bundle size for the dataset quality plugin\r\nby **~55%** and reduces
fragmentation in the chunks when the main page\r\nloads.\r\n\r\n| Before
| After |\r\n|--------|--------|\r\n| <img width=\"525\"
alt=\"Screenshot 2024-10-02 at 09 56
35\"\r\nsrc=\"https://github.com/user-attachments/assets/06fec02c-ff2c-4771-981f-a761bda67eae\">\r\n|
<img width=\"521\" alt=\"Screenshot 2024-10-02 at 09 59
16\"\r\nsrc=\"https://github.com/user-attachments/assets/a243b09a-9d83-4d0d-b875-20855bb18f5d\">\r\n|\r\n|
<img width=\"1398\" alt=\"Screenshot 2024-10-02 at 09 56
55\"\r\nsrc=\"https://github.com/user-attachments/assets/66d2c131-b0b7-47e1-9a9a-e1be57e69bbb\">\r\n|
<img width=\"678\" alt=\"Screenshot 2024-10-02 at 09 58
59\"\r\nsrc=\"https://github.com/user-attachments/assets/39e6515e-5a83-4d97-97c8-cce01b7c6887\">\r\n|\r\n\r\nCo-authored-by:
Marco Antonio Ghiani
<[email protected]>","sha":"ce8c9d8d63ac8d67e975f4cd15cdb665a064d67e","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-logs"],"title":"[Dataset
Quality] Optimize bundle size and chunks
fragmentation","number":194661,"url":"https://github.com/elastic/kibana/pull/194661","mergeCommit":{"message":"[Dataset
Quality] Optimize bundle size and chunks fragmentation (#194661)\n\n## 📓
Summary\r\n\r\nCloses #191602 \r\n\r\nThis work reduces the initial
bundle size for the dataset quality plugin\r\nby **~55%** and reduces
fragmentation in the chunks when the main page\r\nloads.\r\n\r\n| Before
| After |\r\n|--------|--------|\r\n| <img width=\"525\"
alt=\"Screenshot 2024-10-02 at 09 56
35\"\r\nsrc=\"https://github.com/user-attachments/assets/06fec02c-ff2c-4771-981f-a761bda67eae\">\r\n|
<img width=\"521\" alt=\"Screenshot 2024-10-02 at 09 59
16\"\r\nsrc=\"https://github.com/user-attachments/assets/a243b09a-9d83-4d0d-b875-20855bb18f5d\">\r\n|\r\n|
<img width=\"1398\" alt=\"Screenshot 2024-10-02 at 09 56
55\"\r\nsrc=\"https://github.com/user-attachments/assets/66d2c131-b0b7-47e1-9a9a-e1be57e69bbb\">\r\n|
<img width=\"678\" alt=\"Screenshot 2024-10-02 at 09 58
59\"\r\nsrc=\"https://github.com/user-attachments/assets/39e6515e-5a83-4d97-97c8-cce01b7c6887\">\r\n|\r\n\r\nCo-authored-by:
Marco Antonio Ghiani
<[email protected]>","sha":"ce8c9d8d63ac8d67e975f4cd15cdb665a064d67e"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/194661","number":194661,"mergeCommit":{"message":"[Dataset
Quality] Optimize bundle size and chunks fragmentation (#194661)\n\n## 📓
Summary\r\n\r\nCloses #191602 \r\n\r\nThis work reduces the initial
bundle size for the dataset quality plugin\r\nby **~55%** and reduces
fragmentation in the chunks when the main page\r\nloads.\r\n\r\n| Before
| After |\r\n|--------|--------|\r\n| <img width=\"525\"
alt=\"Screenshot 2024-10-02 at 09 56
35\"\r\nsrc=\"https://github.com/user-attachments/assets/06fec02c-ff2c-4771-981f-a761bda67eae\">\r\n|
<img width=\"521\" alt=\"Screenshot 2024-10-02 at 09 59
16\"\r\nsrc=\"https://github.com/user-attachments/assets/a243b09a-9d83-4d0d-b875-20855bb18f5d\">\r\n|\r\n|
<img width=\"1398\" alt=\"Screenshot 2024-10-02 at 09 56
55\"\r\nsrc=\"https://github.com/user-attachments/assets/66d2c131-b0b7-47e1-9a9a-e1be57e69bbb\">\r\n|
<img width=\"678\" alt=\"Screenshot 2024-10-02 at 09 58
59\"\r\nsrc=\"https://github.com/user-attachments/assets/39e6515e-5a83-4d97-97c8-cce01b7c6887\">\r\n|\r\n\r\nCo-authored-by:
Marco Antonio Ghiani
<[email protected]>","sha":"ce8c9d8d63ac8d67e975f4cd15cdb665a064d67e"}}]}]
BACKPORT-->

Co-authored-by: Marco Antonio Ghiani <[email protected]>
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) ci:project-deploy-observability Create an Observability project release_note:skip Skip the PR/issue when compiling release notes Team:obs-ux-logs Observability Logs User Experience Team v8.16.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Dataset Quality] Optimize initial load bundles
5 participants