Open nolanlawson opened 7 years ago
Did some initial analysis using Node 7 and the Pouch test suite, some observations:
console.log()
is the biggest cost; running with -n
to disable logging helps a lotsafeJsonParse
and safeJsonStringify
are 2nd and 3rd most expensive, but replacing with regular JSON.parse
and JSON.stringify
doesn't help because try/catches are no longer deoptimizedrootToLeaf
inside of stem
is 4th most expensive. This doesn't get called much, but when it is called, it can take an extremely long time, as much as ~45ms even on a fast machine (macbook air 2013).
I've done some light perf testing with PouchDB's performance test suite, but I haven't done any heavy-duty performance profiling, and I'm sure there are low-hanging fruit in there. Currently, PouchDB Server seems to be slower than CouchDB in certain scenarios, even when running in in-memory mode (!).
Perf testing is fairly easy; we can just run
node --inspect ./packages/node_modules/pouchdb-server/bin/pouchdb-server
and then run the test suite against it, and use the Chrome Dev Tools' Profiler to see where time is being spent. My hunch is that most of the slowness is due not to PouchDB's LevelDB adapter (which has been pretty strenuously optimized over the years), but rather to this codebase.