-
Notifications
You must be signed in to change notification settings - Fork 4
iterator works slow #12
Comments
hmm yeah a sync version may be nice. I haven't hit performance issues with the next addition I make to this lib should be node 0.11 support, but I may find time for sync iterarors. if you opened a pr, I'd happily merge, btw ;) |
Thanks :) Most probably is slow because of callbacks. I have also compared the performance of Async get/set vs Sync get/set. Async versions are much slower. Also, a new suggestion. Would be very useful to have batch operations, for example to read multiple keys in one shot , a functionality somehow similar to Redis MULTI. e.g. |
yeah, the async stuff has to:
whereas the sync versions:
quite a few less things to do ;) a mutli-get makes sense too. it lands out of scope of the iterator, unless we'd do something like: var iterator = db.iterator()
iterator.next(5 /* get 5 the next keys */, function (err, values) {
if (err) handleError(err)
// values = [ ... ]
}) also, if you run edit:
|
I am already impressed by this library :) seems it is perfect for my needs. It is really fast except Async iterators, according to sophia benchmarks http://sphia.org/benchmarks.html reading data using iterators should by much much faster than using get(key)
|
a sync for sync, maybe something like (this has not been tested!): NAN_METHOD(Iterator::NextSync) {
NanScope();
Iterator *self = ObjectWrap::Unwrap<Iterator>(args.This());
sophia::IteratorResult *result = self->it->Next();
if (result) {
v8::Local<v8::Object> obj = NanNew<v8::Object>();
obj->Set(NanNew("key"), NanNew(result->key));
obj->Set(NanNew("value"), NanNew(result->value));
NanReturnValue(obj);
} else {
NanReturnUndefined();
}
} |
@gabrieldodan I've been working on a new release (1.0.0). I've added |
Thanks, will do some tests tomorrow :) Also if you could implement muti-read that will be great! The idea is to read batch of data in only one call, to avoid too many jumps from JS to C++. An iterator like this:
It doesn't make sense to return object by object, do the iteration on C++ and give me only the results! Will be also useful an option to return only the keys or only the values, or both. Thanks. |
hmm.. iterating like that over a large repository would cause significant performance issues when dealing with any sort of concurrency. assuming we'd only push one task into now, if we queued a job for every read in also: opened separate thread: #13. |
version 1.0.0 now has Will address |
Hi, I have made some performance tests and I noticed that the iterator works very slow. I think is because of callback for each iteration. On each iteration it call the callback function, that's expensive. I think a Sync version for next() function would be very useful, e.g.
iterator.nextSync()
that should return the currentkey/value
pair. What you think ?Besides that, the library is really fast !
The text was updated successfully, but these errors were encountered: