New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parallelize bulkDocs() #2553
Comments
IE 10: 31975ms -> 30803ms (3.66% improvement). |
The issue isn't context switching it's most of the time is spent waiting so This is overall going to be good but you your going to want to put an upper
|
@calvinmetcalf That makes sense. Whatever the reason, it's surprisingly a big speedup. I'm not sure we need to set a limit on the number of parallel executions. Users can control that themselves when they call To be fair, this number could grow a lot in the case of map/reduce if the user is emitting multiple key/values per doc, but that seems like an edge case. In any case, I say we cross that bridge when we get there. |
Would this make sense for leveldb.js too? |
I would double check that doing 100 or 500 or 1000 doc bulk docs are still On Sat, Aug 2, 2014 at 1:27 PM, Nolan Lawson notifications@github.com
-Calvin W. Metcalf |
I refactored the code, so you can take a look at it if you want. I'm just worried that limiting the number of simultaneous calls would make the code complexity worse than it already is, whereas we could also solve that problem by just making the batch size in mapreduce user-configurable, so they have an escape option if it really becomes a problem. |
I'd recommend you re-factoring the code so that you can rewrite the main thing I can do the rewrite for level, but in async we need to avoid 3 stooges syndrome, that is where everybody tries to get through the door at once and nobody actually gets through, e.g. we open up 100 requests and they all starve each other of memory. |
I'd love to use promises, but then both IDB and WebSQL end the transaction early. :( I still don't think you need to solve the three stooges problem at the leveldb.js level. If we just make the batch size for mapreduce configurable, then the user has control over everything, and the defaults are already pretty sensible anyway (50 for mapreduce, 100 for changes/replication). |
Bulk docs is available outside if mapreduce if somebody does db.bulk and an
|
good point |
Done. I put it in |
Fixed in all 3. Thanks @calvinmetcalf . |
OK, so.
I've been trying to think of more ways to speed up secondary indexes. One thought that occurred to me is that the current bulkDocs may be a little inefficient, because it works like this:
Presumably that's a lot of overhead of switching between the JavaScript VM and the C code, when really you could do it all at once (since it's all wrapped in a transaction):
I started writing the code yesterday for IDB and WebSQL. Preliminary results are encouraging (temp-views test with 1 iteration):
The biggest problem I have with the code right now is that it's hard to understand; I need to refactor it first.
The text was updated successfully, but these errors were encountered: