Skip to content

Commit

Permalink
ship IGListExperimentArrayAndSetOptimization
Browse files Browse the repository at this point in the history
Summary: This experiment shows a slight decrease in frame-drops on features that have more expensive hashing, so lets ship!

Reviewed By: lorixx

Differential Revision: D25884785

fbshipit-source-id: a5e33abe6f129166ab9b75de80636db801599b74
  • Loading branch information
maxolls authored and facebook-github-bot committed Jan 22, 2021
1 parent f1a7f70 commit c0cf10d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 62 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ The changelog for `IGListKit`. Also see the [releases](https://github.com/instag

- Improved performance by using `reloadData` when there are too many diffing updates. Shipped with experiment `IGListExperimentReloadDataFallback` from Ryan Nystrom. [Maxime Ollivier](https://github.com/maxolls) (tbd)

- Small performance improvement by replacing `NSSet` with `NSArray` during the data update to avoid unnecessary hashing, especially when dealing with lots of large objects with non trivial hashes. [Maxime Ollivier](https://github.com/maxolls) (tbd)

### Fixes

- `IGListCollectionViewLayout` should get the section/index counts via `UICollectionView` to stay in sync, instead of the `dataSource` [Maxime Ollivier](https://github.com/maxolls) (tbd)
Expand Down
8 changes: 3 additions & 5 deletions Source/IGListDiffKit/IGListExperiments.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ typedef NS_OPTIONS (NSInteger, IGListExperiment) {
IGListExperimentBackgroundDiffing = 1 << 2,
/// Test invalidating layout when cell reloads/updates in IGListBindingSectionController.
IGListExperimentInvalidateLayoutForUpdates = 1 << 3,
/// Test array and set optimization on update
IGListExperimentArrayAndSetOptimization = 1 << 4,
/// Test validating the collectionView count just before performBatchUpdate. `IGListExperimentalAdapterUpdater` only.
IGListExperimentSectionCountValidation = 1 << 5,
IGListExperimentSectionCountValidation = 1 << 4,
/// Test skipping performBatchUpdate if we don't have any updates. `IGListExperimentalAdapterUpdater` only.
IGListExperimentSkipPerformUpdateIfPossible = 1 << 6,
IGListExperimentSkipPerformUpdateIfPossible = 1 << 5,
/// Test skipping creating {view : section controller} map, which has inconsistency issue.
IGListExperimentSkipViewSectionControllerMap = 1 << 7
IGListExperimentSkipViewSectionControllerMap = 1 << 6
};

/**
Expand Down
24 changes: 4 additions & 20 deletions Source/IGListKit/IGListAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#import "IGListDebugger.h"
#import "IGListSectionControllerInternal.h"
#import "IGListTransitionData.h"
#import "IGListUpdatedObjectContainer.h"
#import "IGListUpdatingDelegateExperimental.h"
#import "UICollectionViewLayout+InteractiveReordering.h"
#import "UIScrollView+IGListKit.h"
Expand Down Expand Up @@ -710,17 +709,8 @@ - (IGListTransitionData *)_generateTransitionDataWithObjects:(NSArray *)objects
}
#endif

NSMutableArray<IGListSectionController *> *sectionControllers;
NSMutableArray *validObjects;

if (IGListExperimentEnabled(_experiments, IGListExperimentArrayAndSetOptimization)) {
// Experiment: Pass the capacity count, so that arrays don't have to re-size.
sectionControllers = [[NSMutableArray alloc] initWithCapacity:objects.count];
validObjects = [[NSMutableArray alloc] initWithCapacity:objects.count];
} else {
sectionControllers = [NSMutableArray new];
validObjects = [NSMutableArray new];
}
NSMutableArray<IGListSectionController *> *sectionControllers = [[NSMutableArray alloc] initWithCapacity:objects.count];
NSMutableArray *validObjects = [[NSMutableArray alloc] initWithCapacity:objects.count];

// push the view controller and collection context into a local thread container so they are available on init
// for IGListSectionController subclasses after calling [super init]
Expand Down Expand Up @@ -776,14 +766,8 @@ - (void)_updateWithData:(IGListTransitionData *)data {

IGListSectionMap *map = self.sectionMap;

id<IGListUpdatedObjectContainer> updatedObjects;
if (IGListExperimentEnabled(_experiments, IGListExperimentArrayAndSetOptimization)) {
// Experiment: Avoid using a set, so that we don't need to deal with hashes and equality. The updater
// should have dealt with duplicates already.
updatedObjects = [NSMutableArray new];
} else {
updatedObjects = [NSMutableSet new];
}
// Note: We use an array, instead of a set, because the updater should have dealt with duplicates already.
NSMutableArray *updatedObjects = [NSMutableArray new];

for (id object in data.toObjects) {
// check if the item has changed instances or is new
Expand Down
23 changes: 0 additions & 23 deletions Source/IGListKit/Internal/IGListUpdatedObjectContainer.h

This file was deleted.

14 changes: 0 additions & 14 deletions Source/IGListKit/Internal/IGListUpdatedObjectContainer.m

This file was deleted.

0 comments on commit c0cf10d

Please # to comment.