-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[Performance] Class based HOC implementations are costly #4549
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
Comments
Triggered auto assignment to @MonilBhavsar ( |
The other large portion of execution time is taken by |
cc @marcaaron |
Should we maybe limit the scope of this to just refactoring I'd also be curious to see the effects on chat switching since we have done the test for web but not Android. I'd be curious to see what it does for us on the native side. Is it possible to do a similar trace? I don't have much experience with the hermes debugger but I thought maybe it would be possible to profile there? |
I thought it would be possible to do this with the Hermes debugger in Flipper, but starting the profiler there seems to hang with "Initialising ..." Since all of the hoverable popups should be noop on native, there would be less After analysing this more the HOCs might only be 30-50% to blame, and the rest is due to the many instances of components that use them. Yes the current scope is whatever we can do without massive changes and so far that seems only the We had a test where all popups we removed. Perhaps for a future ticket we can make the same snapshot captured here |
We can just try the |
Managed to get the profiler to work on Android and adding some tips for that in this PR if it helps at all |
Marc, I assigned you as you are having context and working on this |
Whoops! This issue is 2 days overdue. Let's get this updated quick! |
ATM it's not possible to benchmark this with the new performance metrics, as TTI happens before the report screen mounts, where the most We can add marks for chat switches and then do a couple of benchmarks - switch to large, medium, with images, etc... |
Got it. Sounds like this probably will not improve the TTI then. But that's fine - it maybe will help the chat switching as you've mentioned. For that, it might be good to have the Flipper metrics we are discussing in the other issue. |
I think it might be a good idea to add Also seeing the plugin code, it might be possible to do something like new PerformanceObserver((list) => {
list.getEntries()
.filter(entry => entry.name.endsWith('End'))
.forEach(entry => {
const end = entry.name;
const name = end.replace(/End$/, '');
const start = `${name}Start`;
performance.measure(name, start, end);
}
}).observe({type: 'mark', buffered: true}); This would allow us to only put start/end
|
Yep, that sounds like a good idea.
I like that too since it's one less thing to worry about. What if we did that, but also abstracted this detail so that we can just do something like... Performance.start(CONST.TIMING.SOMETHING); // adds the `_start`
Performance.end(CONST.TIMING.SOMETHING); // adds the `_end` |
👍 Even better |
Submitted the PR |
Uh oh! This issue is overdue by 2 days. Don't forget to update your issues! |
Gonna drop this to weekly for now. We are adding more metrics now which should make it easier to test theories. |
I still think many HOCs could be bad, I'll re-capture data now that we have a new way of measuring performance (CAPTURE_METRICS) I'll again measure chat switching (we have perf marks for those)
Both pre/post tests should happen after fresh login (storage is cleared on log out) and without scrolling to the past (which would add more data to storage and force you to pre-render more) |
This issue has not been updated in over 15 days. eroding to Monthly issue. P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do! |
Run some benchmarks on Android, it seems it's almost unaffected by the Setup
Before
After
Apart from that I've measured chat switch time, where I couldn't see any improvement I also captured memory usage:
|
I'm closing this one |
Uh oh!
There was an error while loading. Please reload this page.
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
What performance issue do we need to solve?
What is the impact of this on end-users?
List any benchmarks that show the severity of the issue
unmountHostComponents
withWindowDimensions
HOCswithOnyx
HOCsProfile data (you can load this in Chrome/Performance): https://u.pcloud.link/publink/show?code=XZwvKwXZpXUhxs7Vdr7kaco3HDxznYmcP7sX
Proposed solution (if any)
HOC usages should be gradually reduced as much as possible
They cause 1+ component for each component that uses them
I've described how to change
withWindowDimensions
here: #2326 (DimensionsContextProvider)This will leave
withWindowDimensions
usages throughout the app unchanged, but they will at least not be class based components and would not run class component lifecycleReportActionItem
should be updated not to be HOC based (if possible) as they are the most rendered componentThey can receive window related props from the parent
renderItem
as well as Onyx related propsList any benchmarks after implementing the changes to show impacts of the proposed solution (if any)
Note: These should be the same as the benchmarks collected before any changes.

This is not at all the final result, but it does show some improvement after converting the
withWindowDimensions
wrappings not to be class basedPlatform:
Where is this issue occurring?
Version Number: 1.0.85-0
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
Expensify/Expensify Issue URL:
View all open jobs on Upwork
The text was updated successfully, but these errors were encountered: