Mailspring/script
Ben Gotow 8f17b42074 fix(db): Switch to better-sqlite3, resolves offline issue
Summary:
Better-SQLite3 is a fork of node-sqlite3 which includes a re-written JavaScript interface. It’s more synchronous, but better reflects what is actually sync vs. async in sqlite’s C++ API. (Not much is really async under the hood.) This diff uses a branch of better-sqlite3 I’ve edited to support Node 6.

In my tests, this branch spends 3.24x less time executing queries than `master`. (Measured time spent in calls to `this._db[run|all|get]` over the first 5000 queries of initial sync. It also increased the performance of starring a thread in the thread list by 28%.

This library also allows us to use a prepared statement cache, which is great because we often make the same queries repeatedly as query subscriptions refresh the UI and deltas are dumped into the app. The old interface didn’t expose statements (cached query plans) to JS.

better-sqlite3 advertises that it uses the JS garbage collector instead of lower level C++ memory management. I tested syncing my entire mailbox to verify that memory usage is not significantly different on this branch after a lot of queries have been made.

Finally, it looks like we can finally stop building sqlite3 from scratch in `script/bootstrap`. This library builds properly with `apm install`. 🎉

We might want to change the DatabaseStore and DatabaseTransaction classes more, now that it’s possible to execute queries synchronously. It could make things cleaner and get us out of promise-hell in a few places. In this diff I tried to change as little as possible.

Test Plan: Run tests, everything still works

Reviewers: juan, jackie

Reviewed By: juan, jackie

Differential Revision: https://phab.nylas.com/D3315
2016-10-06 17:01:22 -07:00
..
utils test(contenteditable): add in contenteditable list specs 2015-12-02 13:41:47 -08:00
bootstrap fix(db): Switch to better-sqlite3, resolves offline issue 2016-10-06 17:01:22 -07:00
bootstrap.cmd fix(drafts): Various improvements and fixes to drafts, draft state management 2015-02-03 16:24:31 -08:00
build fix(drafts): Various improvements and fixes to drafts, draft state management 2015-02-03 16:24:31 -08:00
build.cmd fix(drafts): Various improvements and fixes to drafts, draft state management 2015-02-03 16:24:31 -08:00
cibuild Revert "fix(build): Actually make verbose" 2016-04-11 16:12:05 -07:00
cibuild-docker-ubuntu32 build(32-bit): Move a few docker files out of root of repo 2016-03-03 17:03:14 -08:00
cibuild.ps1 feat(ci): add Travis and AppVeyor ci support 2015-12-07 12:48:26 -05:00
clean Fix failing clean script (#2554) 2016-07-08 10:57:12 -07:00
clean.cmd fix(drafts): Various improvements and fixes to drafts, draft state management 2015-02-03 16:24:31 -08:00
docs fix(build): bail if script/bootstrap fails and enhance test output 2015-11-23 14:34:18 -05:00
grunt fix(drafts): Various improvements and fixes to drafts, draft state management 2015-02-03 16:24:31 -08:00
grunt.cmd fix(drafts): Various improvements and fixes to drafts, draft state management 2015-02-03 16:24:31 -08:00
mkdeb build(linux): Ensure that target files are not group writable 2016-01-13 16:09:53 -08:00
mkrpm fix(mkrpm): remove spaces before/after = 2016-02-15 20:26:00 -05:00
rpmbuild fix(drafts): Various improvements and fixes to drafts, draft state management 2015-02-03 16:24:31 -08:00
set-version ci(mac): Rename the app Nylas N1 on the Mac 2015-10-20 18:36:39 -07:00
test fix(drafts): Various improvements and fixes to drafts, draft state management 2015-02-03 16:24:31 -08:00