Improve scroll perf on single section inline update QE

Summary:
= Context =

Thanks to the awesome Comparison View analysis, I am able to pinpoint where the scroll perf regression is for the single section inline update QE.

CV2 link: https://fburl.com/cv/fttkv99b

Also see from the graph that the these call stacks are pretty stat-sig,

https://pxl.cl/14D9M

And from the following stack stats, it's pretty clear that the heaviest one is calling from `-[IGListBindingSingleSectionController didUpdateToObject:]`, Approx. Frame Percentage is 24% to 1% compared to Control test group for my QE.

https://pxl.cl/14Db0

= Root cause =

Basically in my new QE, whenever IGListKit update, the -didUpdateToObject: is called on every single IGListSectionController, which in our case, we would call -[-configureCell:withViewModel:] all every single cells. And it's actually pretty expensive for any cell configuration:

https://pxl.cl/14DbZ

In control group, we never trigger any cell "Re-binding" thus no heavy impact. However the way control group works is, that we always trigger another cell creation and replace with the existing one. IGListKit would still check -isEqualToDiffable: to decide whether the current cell needs a reload, the logic is inside IGListAdapterUpdater.

= Solution =

It's easy, just do a simple `-isEqualtoDiffable:` check before updating the _item, inside `[-IGListBindingSingleSectionController didUpdateToObject:]` method.

Differential Revision: D20909174

fbshipit-source-id: 59d57fc8ddda7210cd1ae333942a345025cf1ee3
This commit is contained in:
Zhisheng Huang 2020-04-08 11:44:47 -07:00 committed by Facebook GitHub Bot
parent b7db8c5fe1
commit 9fcc122ed0

View file

@ -15,7 +15,7 @@
@end
@implementation IGListBindingSingleSectionController {
id _item;
id<IGListDiffable> _item;
__weak UICollectionViewCell *_displayingCell;
}
@ -68,7 +68,10 @@
return cell;
}
- (void)didUpdateToObject:(id)object {
- (void)didUpdateToObject:(id<IGListDiffable>)object {
if ([_item isEqualToDiffableObject:object]) {
return;
}
_item = object;
if (_enabledCellConfigurationDuringUpdate) {