Skip to content

Conversation

@nolanlawson
Copy link
Member

Adds a new test to browser.worker.js. The test fails before the fix but succeeds after, demonstrating the issue with docCount.

I'll need to run some perf tests to see what kind of impact this has, but I believe that since we can now use getAll()-based cursors for allDocs(), we can offset whatever perf regression this causes. Also it's the right thing to do because it's more correct.

I will have to implement the same fix for WebSQL (due to the cross-tab issue) but I'll do that in another PR. The worker test does not run for WebSQL because no modern browser supports WebSQL in a worker.

var error = new Error('db isn\'t open');
error.id = 'idbNull';
return callback(error);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting idb to null was not necessary; we can just check cachedDBs.

Also, there is no need to manually check for closed state because adapter.js already does that.

});
});
});

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran into a quasi-unrelated bug with closed so I wanted more tests to confirm it was working correctly.


after(function () {
worker.terminate();
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

creating and terminating a new worker for every test here was really not necessary

Removes this unsafe optimization.
@nolanlawson
Copy link
Member Author

Ran some measurements using #6067. This is a regression on the all-docs-startkey-endkey test in Chrome but not in Firefox:

Chrome: 631ms -> 1081ms
Firefox: 411ms -> 414ms

My guess is that Firefox is caching the count somehow under the hood (or SQLite is just very smart about this), whereas Chrome isn't. Regardless, this PR is the correct behavior, and it's better to be correct than to be fast. My tests in #6060 indicate that we can still get some wins, although I don't know if we can get Chrome to be as fast as it used to be.

@nolanlawson
Copy link
Member Author

It's also a modest perf regression in Edge 15 (beta): 1717ms -> 1517ms

@daleharvey
Copy link
Contributor

Being correct > Being fast

@daleharvey daleharvey merged commit fa2b3a6 into master Dec 26, 2016
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

Successfully merging this pull request may close these issues.

2 participants