-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Breaking: prefer backpressure over snapshot guarantees
Previously (in `level-js`) an iterator would keep reading in the background so as to keep the IndexedDB transaction alive and thus not see the data of simultaneous writes. I.e. it was reading from a snapshot in time. The downsides of that approach: - Memory usage on large databases - IndexedDB doesn't actually use a snapshot (Chrome used to) but rather a blocking transaction. Meaning you can't write while an iterator is reading. So instead, an iterator now reads a few entries ahead and then opens a new transaction on the next read. A "few" means all entries for `iterator.all()`, `size` amount of entries for `iterator.nextv(size)` and a hardcoded 100 entries for `iterator.next()`. Individual calls to those methods still have snapshot guarantees, but repeated calls do not. Reading should now be faster too, because it uses the `getAll()` and `getAllKeys()` methods of IndexedDB, instead of a cursor. This means multiple entries are transferred from IndexedDB to JS in a single turn of the JS event loop, rather than one turn per entry. Reverse iterators do still use a cursor and are therefor slower. To reflect the new behavior, `db.supports.snapshots` is now false. Ref Level/level-js#86
- Loading branch information
Showing
3 changed files
with
155 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters