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

PLAT-109381: Reduce the ImageItem render time #2790

Open
wants to merge 29 commits into
base: develop
Choose a base branch
from

Conversation

ybsung
Copy link
Contributor

@ybsung ybsung commented Jun 15, 2020

Checklist

  • I have read and understand the contribution guide
  • A CHANGELOG entry is included
  • At least one test case is included for this feature or bug fix
  • Documentation was added or is not needed
  • This is an API breaking change

Issue Resolved / Feature Added

One of the major cause for the list scroll performance is the long JS execution time of the ImageItem. So we need to reduce the ImageItem render time.

Resolution

  1. Memoization of the kind computed values and some React elements.
  2. Pass children for caption, label for subcaption, imageIconComponent, imageIconSrc, and src not as props but thought a context so that we don't have to render several components again.
  3. Update the caption, subcaption, and data-index DOM elements directly instead of rendering components.

Additional Considerations

Links

PLAT-109381
Related PR: enactjs/sandstone#461
Previous Branch: https://github.com/enactjs/enact/tree/PLAT-109381-useMemo2

Comments

Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])

Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
ybsung added 2 commits June 16, 2020 13:52
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
@codecov
Copy link

codecov bot commented Jun 16, 2020

Codecov Report

Merging #2790 into develop will increase coverage by 0.18%.
The diff coverage is 93.33%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2790      +/-   ##
===========================================
+ Coverage    44.61%   44.80%   +0.18%     
===========================================
  Files          163      164       +1     
  Lines         8158     8187      +29     
  Branches      1991     1994       +3     
===========================================
+ Hits          3640     3668      +28     
- Misses        3391     3392       +1     
  Partials      1127     1127              
Impacted Files Coverage Δ
packages/ui/ImageItem/MemoPropsDecorator.js 87.50% <87.50%> (ø)
packages/ui/ImageItem/ImageItem.js 100.00% <100.00%> (ø)
packages/ui/Layout/Layout.js 100.00% <0.00%> (+5.55%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d4e3d22...da1c155. Read the comment docs.

ybsung added 3 commits June 17, 2020 09:22
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
ybsung added 11 commits June 17, 2020 17:31
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
ybsung added 7 commits June 18, 2020 00:59
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
ybsung added 2 commits June 18, 2020 15:25
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Copy link
Contributor

@MikyungKim MikyungKim left a comment

Choose a reason for hiding this comment

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

Much better shape! Thank you for your efforts.
LGTM!

Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Copy link
Contributor

@webOS101 webOS101 left a comment

Choose a reason for hiding this comment

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

It's not completely clear to me that each of these changes is required to get the performance necessary. In fact, there may be performance and memory regressions from this. Certainly this is much more complicated and it may not be a general solution that could be applied to different components. I'm also not certain that many of the issues might not be resolved by making portions of the components Pure or by taking other approaches other than using context.

There's not a clear breakdown by how much improvement each piece of this gives to the overall performance. Because of the complexity, I don't think we can move forward with this solution right now.

If we really need to go further, then it seems like we might want to just directly mutate the DOM in these special instances. At least, we'd know the trade-offs we're making in terms of performance for this (and other) components.

},

render: ({children, css, imageComponent, orientation, placeholder, src, ...rest}) => {
render: ({className, memoizedChildrenCell, memoizedImageCell, orientation, ...rest}) => {
delete rest.css;
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to delete css, I believe it's non-enumerable.

const omitted = omit(filter, props) || {};

return (
<MemoPropsContext.Provider value={picked}>
Copy link
Contributor

Choose a reason for hiding this comment

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

This will force the component to update every time it receives props, even if the values are exactly the same, because the object has changed and context will force the update. Some form of memoization should be done if this truly is the desired solution.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants