I run into performance issues with the diffable data source when having a larger data set, around 22,000 items. I am surprised that applying the snapshot takes so much time when animation is ON. See the code section:
let shouldAnimate = tableView.numberOfSections != 0
apply(snapshot as NSDiffableDataSourceSnapshot<String, NSManagedObjectID>, animatingDifferences: shouldAnimate)
Note: there is a good resource here by Jesse Squires:
My questions is, am I missing something or diffable data source cannot handle this any faster given that applying a snapshot is an O(n) operation?
Turning off animation, same as reloadData
, would somewhat help.
The sample code was setup based on this article by the awesome SwiftLee.
Please see the sample project here.
Sample video here.
Update (September 2nd, 2021): A good Twitter discussion here.
Sidenote:
The sample app can be improved by not setting the fetchBatchSize
since the request is used with a NSFetchedResultsController
. See link.