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

Verify that ForestDB store's allDocs query is actually faster than SQLite store's allDocs #991

Closed
zgramana opened this issue Dec 5, 2015 · 4 comments

Comments

@zgramana
Copy link
Contributor

zgramana commented Dec 5, 2015

Hideki has some evidence that suggests CBForest's iteration on allDocs query is actually slower than SQLite's.

@snej
Copy link
Contributor

snej commented Dec 5, 2015

Hideki and I went over this last month. allDocs iteration on iOS is extremely fast, both in CBL/iOS and with the CBForest C API. It must be something related to the JNI glue that makes it slow.

@borrrden
Copy link
Member

I was in on this meeting as well, it's not the fact that Java is slower than CBForest, but we want to know if SQLite on iOS is faster or slower than ForestDB on iOS for the allDocs query.

@snej
Copy link
Contributor

snej commented Dec 11, 2015

OK, I can rig up a comparative test for that.

@snej snej self-assigned this Dec 11, 2015
@zgramana zgramana added the ready label Dec 11, 2015
@snej snej added in progress and removed ready labels Dec 14, 2015
@snej
Copy link
Contributor

snej commented Dec 15, 2015

tl;dr: allDocs looks to be exactly the same speed with ForestDB vs SQLite, on iOS.

I modified a WorkerBee test and looked at allDocs time for ForestDB and SQLite on my iPhone 6+. The code being benchmarked is:

    CBLQuery* query = [self.database createAllDocumentsQuery];
    query.allDocsMode = kCBLIncludeDeleted;
    CBLQueryEnumerator* rowEnum = [query run: &error];
    for (CBLQueryRow* row in rowEnum) {
        @autoreleasepool {
            key = row.key;
            value = row.value;
        }
    }

(I don't know why Ashvinder left the includeDeleted flag on, but it shouldn't make a difference in timing since the db contains no deleted docs.)

With a database of 10000 docs, 1000 bytes each, SQLite and ForestDB each took 154ms.
With 100 docs, 100000 bytes each, SQLite and ForestDB each took 1.3ms.

In other words, each storage engine takes on the order of 10µs per document, scaling up slightly as the number of docs increases.

(I profiled this in Instruments, and significantly less than half the time is spent in CBForest; the rest is Obj-C overhead and allocating CBL objects. So the CBForest C API should be faster than this.)

@snej snej closed this as completed Dec 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants