DateTime: avoid unnecessary update #6110

Merged
infinite-persistence merged 1 commit from ip/date.time.optimization into master 2021-05-25 00:29:58 +02:00
infinite-persistence commented 2021-05-24 04:09:59 +02:00 (Migrated from github.com)

Issue

Part of #5834 Performance investigation

In a homepage with 120 tiles, the lists get rendered 3 times during initial update*. The sub-components are updating recursively*, so instead of 120 DateTime renders, we have 1000+ renders.
*will investigate separately on the 3-updates + why recursively

image

The resolved DateTime string for timeAgo rarely changes, and even if the string was "a few seconds ago", there's no real need to constantly update it.

Change

Require a minimum 1-minute delta when deciding whether the component should update. Clients can change this value as needed.

After:
image

Test

  • Verified shouldComponentUpdate doesn't end up taking more time than not having it (it's in micro-second range, compared to the millisecond render).
  • Profiler showed no significant improvement for low number of DateTime components, but for the 120 DateTime case, almost 1/4 of a second is saved.
## Issue Part of [#5834 Performance investigation](https://github.com/lbryio/lbry-desktop/issues/5834) In a homepage with 120 tiles, the lists get rendered 3 times during initial update*. The sub-components are updating recursively*, so instead of 120 DateTime renders, we have 1000+ renders. <sub>*will investigate separately on the 3-updates + why recursively</sub> ![image](https://user-images.githubusercontent.com/64950861/119286869-e3911b80-bc77-11eb-8a6d-e671e9ace94a.png) The resolved DateTime string for `timeAgo` rarely changes, and even if the string was "a few seconds ago", there's no real need to constantly update it. ## Change Require a minimum 1-minute delta when deciding whether the component should update. Clients can change this value as needed. After: ![image](https://user-images.githubusercontent.com/64950861/119286789-bd6b7b80-bc77-11eb-8b92-41646d816afa.png) ## Test - [x] Verified `shouldComponentUpdate` doesn't end up taking more time than not having it (it's in micro-second range, compared to the millisecond render). - [x] Profiler showed no significant improvement for low number of DateTime components, but for the 120 DateTime case, almost 1/4 of a second is saved.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: LBRYCommunity/lbry-desktop#6110
No description provided.