-
-
Notifications
You must be signed in to change notification settings - Fork 44
swap out idbwrapper with straight indexeddb code #46
Comments
idb-blob-store chunks messages, so you can probably get even faster with raw idb |
I agree, and not just for speed. That would solve the issue on the null
|
Guys, I've been working on replacing idb-wrapper with native indexedDB. I do have a working implementation ready[1]. But before I open up a PR I'd like to discuss the approach I've taken which is to store JS types natively and only coerce in _get() or _iterator() if asBuffer is true. Otherwise, if asBuffer is false, always return the native type. Previously this behavior was available via options.raw. This required only one patch in the tests of abstract-leveldown (which I will submit if you guys think this is the right approach). Additional changes worth mentioning (see commits in [1]):
open:
destroy:
batch:
iterator:
put:
get:
del:
[1] living in https://github.com/timkuijsten/level.js/tree/idbunwrapper |
According to observations noted in #51 (comment) (aggressive IndexedDB cursor timeouts) I've reworked the iterator to reopen a cursor if the stream is not ended and the end of the cursor was not reached. |
Just realized that automatically reopening a new cursor on a transaction timeout breaks the default snapshot property of leveldb and indexeddb. I've added the |
It would be better to cache cursor results, so that it doesn't matter when
How about naming it |
and
I like the idea in general, but I'm not sure what cache.push and shift for every item do to performance/GC. Furthermore, if a large database is iterated with a slow stream consumer then big memory spikes might occur.
Sounds good. Would be nice to have some feedback from one of the maintainers. |
No way around that, sadly. One can get proper snapshotting or proper backpressure, but not both. All |
Just wanted to chime in to say apologies I haven't been able to dive in to provide feedback on this yet, I think the work here is really awesome so far. One question I have re: snapshots on top of IDB in general (not something I've thought about much until this point): Does creating a new cursor mean creating a snapshot based at a later point in time? Or can you create a cursor pointing at some old state to at least get the same read state out of the db as the previous one. Re: the caching proposal, I do think we should find a way to paper over the TransactionInactiveError issue so that users of e.g. leveldown backed by level.js won't have to know/worry about it. I think in general a default mode should try to prioritize compatibility with modules that will be running in node on leveldown, so we should try to make snapshot semantics match as much as possible. If people want to tune performance in the browser it should be an opt-in. |
Yes. The implementation might not use snapshots, but effectively, for the purposes of this discussion, yes. It means creating a new readonly transaction, which guarantees:
|
I've just pushed a fairly big update of the iterator. I've replaced the I've split out the indexeddb cursor iterator into a separate module so that it can be used as a nodejs stream. It hopefully makes the iterator in level.js a bit easier to read and understand. p.s. I've also tried to upgrade to abstract-leveldown 2.6.0, but this introduces some problems with serializing object values and I was not able to get the new |
Regarding encoding and serialization:
@timkuijsten seeing as I already implemented the above in a private fork, I can publish that if you want, but I can't make promises as to when. One other note, with regards to removing IDBWrapper. I'm using function next() {
if (index === ops.length) return
var op = ops[index++]
, req = op.type === 'del' ? store.delete(op.key) : store.put(op.value, op.key)
req.onsuccess = next
req.onerror = onRequestError
} |
idbwrapper has outlived its usefulness to us, and has performance issues
fastest throughput I can get with idbwrapper is 60KB/s. Without it I can get 1MB/s (using substacks idb-blob-store module which uses the IDB API directly)
The text was updated successfully, but these errors were encountered: