-
Notifications
You must be signed in to change notification settings - Fork 44
PouchDB: evalFunctionInVm performance issue. #1627
Comments
updateViewInQueue(view) calls processNextBatch() processNextBatch() calls tryCode(view.sourceDB, mapFun, [doc]) tryCode(db, fun, args) calls fun.apply(null, args) where
The sandbox (aka VM) is created for every item in the result list and that causes a significant performance issue. |
Note that this bug started life as thaliproject/jxcore#82, which itself started life from thaliproject/leveldown-mobile#4 (where there is sample code that repro's this issue). |
So it seems like the core of our problem is that vm.runInNewContext runs 90x too slow on JXcore versus anywhere else. So we want to get rid of it. I sent mail to Nolan looking at three options:
|
I talked with Nolan and there are a couple of options for us here. Using the list above:
|
I modified our test app to add pouchdb-find tests: The results of query/find execution are as follow for 6000 documents: As you can see the for WebView there is no difference - building the index for the first usage is similar like building the view. However, for jxcore we are getting significant improvement - we are getting the same result as in WebView. |
Quick update: Using pouchdb-find instead of views works for us so we are fine at this moment. |
The map reduce code invokes evalFunctionInVm even for non user defined functions.
https://github.com/pouchdb/pouchdb/blob/master/packages/node_modules/pouchdb-mapreduce/src/index.js#L477
https://github.com/pouchdb/pouchdb/blob/master/packages/node_modules/pouchdb-mapreduce/src/evalFunctionInVm.js
Test results using https://github.com/czyzm/TestViewsJx with JXcore and V8:
The text was updated successfully, but these errors were encountered: