From 1d773aa533a09ded6548fcfb42dec5070b825221 Mon Sep 17 00:00:00 2001 From: Ryan Nystrom Date: Thu, 6 Jul 2017 09:31:00 -0700 Subject: [PATCH] RFC: Diff in the background Summary: Experimenting with a new change. We have observed instances of very large (3k+) lists stalling, even on modern devices. This is especially noticeable if the models being diffed are: - Immutable - `performUpdates:` often and models are alloc/init'd each time - The `isEqualToDiffableObject:` is sort of expensive (many `-[NSString isEqualToString:]` across thousands of models or something) Instead of just rolling this out, I plan on experimenting with results and seeing how much of a performance and stability boost we gain w/ this. Things to measure: - Scroll performance - CPU stalls - WatchDog kills on older devices Closes https://github.com/Instagram/IGListKit/pull/841 Reviewed By: amonshiz Differential Revision: D5364127 Pulled By: rnystrom fbshipit-source-id: 31d50d2e4b3c7c73584d6ec521a9047efd83f315 --- Source/Common/IGListExperiments.h | 2 + Source/IGListAdapterUpdater.m | 74 +++++++++++++++++++++---------- 2 files changed, 52 insertions(+), 24 deletions(-) diff --git a/Source/Common/IGListExperiments.h b/Source/Common/IGListExperiments.h index c47166c6..087307ed 100644 --- a/Source/Common/IGListExperiments.h +++ b/Source/Common/IGListExperiments.h @@ -18,6 +18,8 @@ NS_SWIFT_NAME(ListExperiment) typedef NS_OPTIONS (NSInteger, IGListExperiment) { /// Specifies no experiments. IGListExperimentNone = 1 << 1, + /// Test updater diffing performed on a background queue. + IGListExperimentBackgroundDiffing = 1 << 2, }; /** diff --git a/Source/IGListAdapterUpdater.m b/Source/IGListAdapterUpdater.m index 33b24548..5ed51e0a 100644 --- a/Source/IGListAdapterUpdater.m +++ b/Source/IGListAdapterUpdater.m @@ -176,9 +176,17 @@ static NSArray *objectsWithDuplicateIdentifiersRemoved(NSArray