Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Items get loaded into memory, needs improving. #30

Open
az-oolloow opened this issue Mar 26, 2019 · 9 comments
Open

Items get loaded into memory, needs improving. #30

az-oolloow opened this issue Mar 26, 2019 · 9 comments
Assignees

Comments

@az-oolloow
Copy link

az-oolloow commented Mar 26, 2019

Basically, looking at how the control is laid out, all the data has to be loaded into currentRowViewModels.
So while the delegate has a good api that would allow it to provide data sequentially (e.g. from remote api or sqlite db), in practice all the data is loaded into memory in one go.
So if you have just a measly 10K rows over 5 columns, performance is very poor because just to load the data the control does the foreach over that data...

Look at UITableViewDataSource for ideas on improving this.

@altagir
Copy link

altagir commented Mar 26, 2019

I guess this is due to the sorting capability which double the source and sorted data ?
maybe the sorting should be delegated to view controller calling

@pavankataria
Copy link
Owner

By the sounds of it it sounds like it might be more than just the double the source..
I can see the issues here loading it all into memory, of course.
@az-oolloow Could you create a sample project with the bare essentials that demonstrates the issue you explained?
You can create a github repo or whatever you prefer, so we can check it out.

@pavankataria
Copy link
Owner

Any updates on this?

@altagir
Copy link

altagir commented Mar 28, 2019

To do a simple test :

in DataTableWithDataSourceViewController.swift :

    func randomString(_ length: Int) -> String {
        let letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
        return String((0..<length).map{ _ in letters.randomElement()! })
    }

    public func addDataSourceAfter() {
        for _ in 1...10000 {
            self.dataSource.append( [
                DataTableValueType.string(randomString(12)),
                DataTableValueType.string(randomString(8)),
                DataTableValueType.string(randomString(10)),
                DataTableValueType.string(randomString(15)),
                DataTableValueType.float(175.25)
                ])
        }

        dataTable.reload()
    }

Since sort is slow with huge data set, a spinner could be useful also, if sorting time > 0.2s for example

But I also think using 10000 entries is not really practical.... as of right now you have to scroll to the end, page by page.
isn't there a way to jump the scroll in the collectionview ? i.e. tapping on the right scroll position would directly move you to that page. could be very useful

@pavankataria
Copy link
Owner

Or we could supply the datasource on the fly, but this does mean having to calculate the row heights somehow too.. I imagine this would provide a choppy experience.

@pavankataria
Copy link
Owner

Loading 10000 items isn't practical. There'll be memory issues too..

@altagir
Copy link

altagir commented Mar 30, 2019

Why calculate the row height? Aren't they constants?

@pavankataria
Copy link
Owner

Custom heights can be returned.

@pavankataria pavankataria changed the title Performance is atrocious for large number of items, because everything is loaded into memory Items get loaded into memory, needs improving. Apr 6, 2019
@pavankataria
Copy link
Owner

If anyone has any suggestions I'd love to hear them.

@pavankataria pavankataria pinned this issue Jun 19, 2019
@pavankataria pavankataria unpinned this issue Jun 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants