Giter VIP home page Giter VIP logo

Comments (4)

wtmoose avatar wtmoose commented on June 4, 2024

I’ve had problems with UICollectionView’s internal batch update process getting extremely slow with large updates. If you're using UICollectionView, I would suggest profiling it.

I don't completely understand what you mean by "loading". Can you describe what components of TLIPT you're using, e.g. TLCollectionViewController, TLIndexPathController, etc. and how you're creating and updating your data model?

from tlindexpathtools.

ghazel avatar ghazel commented on June 4, 2024

Yes, perfomBatchUpdates is hidiously slow with >100 items.

By loading I mean; setting items, which builds all the lookup tables. Easy to see in the Shuffle/Filter demo by making an array of 5k items (make sure they are unique).

from tlindexpathtools.

wtmoose avatar wtmoose commented on June 4, 2024

I was able to get the Shuffle demo with 5000 items in Simulator down to 2.5s from 15s. The remaining 2.5s was made up of:

  1. 2.0s in [UICollectionView _endItemAnimations] mainly manipulating index paths. There is nothing I can do about this.
  2. 0.5s in AutoReleasePoolPage::pop(void*). A lot of this is likely due to temporary objects created in TLIndexPathUpdates, but I don't know how much this can be improved and it could be a significant undertaking that I don't have time for.

The issue is summarized as follows. Ultimately, the problem was that the data model items were arrays:

NSArray *items = @[
       @[@"A", [UIColor colorWithHexRGB:0x443695]],
       @[@"B", [UIColor colorWithHexRGB:0x00B1D7]],
       @[@"C", [UIColor colorWithHexRGB:0xF42994]],
       @[@"D", [UIColor colorWithHexRGB:0x0A0916]],
       @[@"E", [UIColor colorWithHexRGB:0xF4E353]],
       @[@"F", [UIColor colorWithHexRGB:0x537B28]],
       ];

TLIPT was calling isEqual on these arrays a lot and this was really slow. The fix involves two changes. The first change was a performance optimization I made in TLIPT to eliminate a bunch of isEqual calls. You'll need to update to version 0.3.8. The second change, which is something you'll probably need to do in our code, was to provide an explicit identifier for each data model item. isEqual gets called on the identifier instead of the item and, with an appropriate choice of identifier, this is much, much faster.

Item identifiers are discussed in the TLIndexPathDataModel API documentation in the "Item Identification" section. The short story is that, in some cases such as the Shuffle example, the item itself is used as the identifier. And if the item's isEqual method is expensive, the data model will not scale. The way to fix this is to provide an explicit unique identifier with a fast isEqual method, such as an NSString. The various TLIndexPathDataModel initializers provide a few options for specifying identifiers. In the Shuffle example, I used the block-based initializer and the first element of the array, i.e. the unique string, as the identifier:

self.indexPathController.dataModel = [[TLIndexPathDataModel alloc] initWithItems:items sectionNameBlock:nil identifierBlock:^id(id item) {
    return item[0];
}];

Thats about it. Please let me know if this helps your project.

from tlindexpathtools.

wtmoose avatar wtmoose commented on June 4, 2024

No reply. Closing.

from tlindexpathtools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.