-
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
[Cloud Security] Improve graph component performance #204983
Conversation
d995dbb
to
6f02b77
Compare
Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security) |
- Avoiding sub-pixel rendering - Toggled `onlyRenderVisibleElements` to improve performance
41543eb
to
f1950ad
Compare
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.
CR only.
Looks good and memoizing this component makes a lot of sense considering how much is going on. I'm not too familiar with the entire component so I mainly added comments about improving readability for now.
...ions/security/packages/kbn-cloud-security-posture/graph/src/components/edge/default_edge.tsx
Outdated
Show resolved
Hide resolved
const sourceMargin = getShapeHandlePosition(data?.sourceShape); | ||
const targetMargin = getShapeHandlePosition(data?.targetShape); | ||
const markerStart = | ||
data?.sourceShape !== 'label' && data?.sourceShape !== 'group' |
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.
consider exporting constants for core values like label
and group
here
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 didn't find a convenient name for sharing constants' literals that are used in schema. Do you have an example? (both sourceShape
and targetShape
are well defined types)
I tried using enum, but that causes more duplications of typings than good.
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.
SHAPE_LABEL
, SHAPE_GROUP
or an object that can be used like SHAPES.LABEL
, SHAPES.GROUP
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.
When I tried it I placed the constants in the /types
and used them in the /schema
definition. However, the types are defined by schema
as well, so it creates cyclic references and when I split it into multiple files and tried to work with it, it didn't recognize it as the same type in some scenarios.
can you try it yourself? I'm probably missing something
...ions/security/packages/kbn-cloud-security-posture/graph/src/components/edge/default_edge.tsx
Outdated
Show resolved
Hide resolved
...ions/security/packages/kbn-cloud-security-posture/graph/src/components/edge/default_edge.tsx
Outdated
Show resolved
Hide resolved
maxZoom={1.3} | ||
minZoom={0.1} |
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.
not important right now but in general there are a lot of settings scattered around which might be better to export as consts from one file or object, to make it easier to configure in the future if needed
...ions/security/packages/kbn-cloud-security-posture/graph/src/components/graph/fps_monitor.tsx
Outdated
Show resolved
Hide resolved
...ns/security/packages/kbn-cloud-security-posture/graph/src/components/graph/fps_trendline.tsx
Show resolved
Hide resolved
...ns/security/packages/kbn-cloud-security-posture/graph/src/components/graph/fps_trendline.tsx
Outdated
Show resolved
Hide resolved
...ions/security/packages/kbn-cloud-security-posture/graph/src/components/graph/fps_monitor.tsx
Outdated
Show resolved
Hide resolved
...y/packages/kbn-cloud-security-posture/graph/src/components/graph/graph_benchmark.stories.tsx
Outdated
Show resolved
Hide resolved
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.
Same as @JordanSh, I'm not too familiar with this feature, but mostly I added comments about readability and simplicity. Feel free to ignore 👍
Starting backport for target branches: 8.x |
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
|
## Summary Apply some graph optimizations and added the first graph benchmark storybook. You can read the detailed investigation process [here](elastic#204982 (comment)). I kept the dashed lines until a new design will be introduced. Before: https://github.com/user-attachments/assets/145a82c0-dbd0-410f-a451-eaa8adcc931b After: https://github.com/user-attachments/assets/3c13cae5-85d2-481b-8fc6-cec08ecee0d9 **How to test this PR** To test this PR you can run ``` yarn storybook cloud_security_posture_packages ``` Or open the storybook link attached to the build message ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios (cherry picked from commit d5fe929)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…205148) # Backport This will backport the following commits from `main` to `8.x`: - [[Cloud Security] Improve graph component performance (#204983)](#204983) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Kfir Peled","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-24T18:52:26Z","message":"[Cloud Security] Improve graph component performance (#204983)\n\n## Summary\r\n\r\nApply some graph optimizations and added the first graph benchmark\r\nstorybook.\r\n\r\nYou can read the detailed investigation process\r\n[here](https://github.com/elastic/kibana/issues/204982#issuecomment-2559715178).\r\n\r\nI kept the dashed lines until a new design will be introduced.\r\n\r\nBefore:\r\n\r\n\r\nhttps://github.com/user-attachments/assets/145a82c0-dbd0-410f-a451-eaa8adcc931b\r\n\r\n\r\nAfter:\r\n\r\n\r\nhttps://github.com/user-attachments/assets/3c13cae5-85d2-481b-8fc6-cec08ecee0d9\r\n\r\n\r\n**How to test this PR**\r\n\r\nTo test this PR you can run\r\n\r\n```\r\nyarn storybook cloud_security_posture_packages\r\n```\r\n\r\nOr open the storybook link attached to the build message\r\n\r\n### Checklist\r\n\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"d5fe9290e80a1b7ac05861804e0fa0e42f05572d","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Cloud Security","backport:prev-minor","ci:build-storybooks"],"title":"[Cloud Security] Improve graph component performance","number":204983,"url":"https://github.com/elastic/kibana/pull/204983","mergeCommit":{"message":"[Cloud Security] Improve graph component performance (#204983)\n\n## Summary\r\n\r\nApply some graph optimizations and added the first graph benchmark\r\nstorybook.\r\n\r\nYou can read the detailed investigation process\r\n[here](https://github.com/elastic/kibana/issues/204982#issuecomment-2559715178).\r\n\r\nI kept the dashed lines until a new design will be introduced.\r\n\r\nBefore:\r\n\r\n\r\nhttps://github.com/user-attachments/assets/145a82c0-dbd0-410f-a451-eaa8adcc931b\r\n\r\n\r\nAfter:\r\n\r\n\r\nhttps://github.com/user-attachments/assets/3c13cae5-85d2-481b-8fc6-cec08ecee0d9\r\n\r\n\r\n**How to test this PR**\r\n\r\nTo test this PR you can run\r\n\r\n```\r\nyarn storybook cloud_security_posture_packages\r\n```\r\n\r\nOr open the storybook link attached to the build message\r\n\r\n### Checklist\r\n\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"d5fe9290e80a1b7ac05861804e0fa0e42f05572d"}},"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/204983","number":204983,"mergeCommit":{"message":"[Cloud Security] Improve graph component performance (#204983)\n\n## Summary\r\n\r\nApply some graph optimizations and added the first graph benchmark\r\nstorybook.\r\n\r\nYou can read the detailed investigation process\r\n[here](https://github.com/elastic/kibana/issues/204982#issuecomment-2559715178).\r\n\r\nI kept the dashed lines until a new design will be introduced.\r\n\r\nBefore:\r\n\r\n\r\nhttps://github.com/user-attachments/assets/145a82c0-dbd0-410f-a451-eaa8adcc931b\r\n\r\n\r\nAfter:\r\n\r\n\r\nhttps://github.com/user-attachments/assets/3c13cae5-85d2-481b-8fc6-cec08ecee0d9\r\n\r\n\r\n**How to test this PR**\r\n\r\nTo test this PR you can run\r\n\r\n```\r\nyarn storybook cloud_security_posture_packages\r\n```\r\n\r\nOr open the storybook link attached to the build message\r\n\r\n### Checklist\r\n\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"d5fe9290e80a1b7ac05861804e0fa0e42f05572d"}}]}] BACKPORT--> Co-authored-by: Kfir Peled <[email protected]>
## Summary Apply some graph optimizations and added the first graph benchmark storybook. You can read the detailed investigation process [here](elastic#204982 (comment)). I kept the dashed lines until a new design will be introduced. Before: https://github.com/user-attachments/assets/145a82c0-dbd0-410f-a451-eaa8adcc931b After: https://github.com/user-attachments/assets/3c13cae5-85d2-481b-8fc6-cec08ecee0d9 **How to test this PR** To test this PR you can run ``` yarn storybook cloud_security_posture_packages ``` Or open the storybook link attached to the build message ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
## Summary Apply some graph optimizations and added the first graph benchmark storybook. You can read the detailed investigation process [here](elastic#204982 (comment)). I kept the dashed lines until a new design will be introduced. Before: https://github.com/user-attachments/assets/145a82c0-dbd0-410f-a451-eaa8adcc931b After: https://github.com/user-attachments/assets/3c13cae5-85d2-481b-8fc6-cec08ecee0d9 **How to test this PR** To test this PR you can run ``` yarn storybook cloud_security_posture_packages ``` Or open the storybook link attached to the build message ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
## Summary Apply some graph optimizations and added the first graph benchmark storybook. You can read the detailed investigation process [here](elastic#204982 (comment)). I kept the dashed lines until a new design will be introduced. Before: https://github.com/user-attachments/assets/145a82c0-dbd0-410f-a451-eaa8adcc931b After: https://github.com/user-attachments/assets/3c13cae5-85d2-481b-8fc6-cec08ecee0d9 **How to test this PR** To test this PR you can run ``` yarn storybook cloud_security_posture_packages ``` Or open the storybook link attached to the build message ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
Summary
Apply some graph optimizations and added the first graph benchmark storybook.
You can read the detailed investigation process here.
I kept the dashed lines until a new design will be introduced.
Before:
Screen.Recording.2024-12-23.at.14.04.26.mov
After:
Untitled.mov
How to test this PR
To test this PR you can run
Or open the storybook link attached to the build message
Checklist