{"action":"created","issue":{"url":"https://api.github.com/repos/pouchdb/pouchdb/issues/4861","labels_url":"https://api.github.com/repos/pouchdb/pouchdb/issues/4861/labels{/name}","comments_url":"https://api.github.com/repos/pouchdb/pouchdb/issues/4861/comments","events_url":"https://api.github.com/repos/pouchdb/pouchdb/issues/4861/events","html_url":"https://github.com/pouchdb/pouchdb/pull/4861","id":130067948,"number":4861,"title":"(#4861) - faster json parse","user":{"login":"nolanlawson","id":283842,"avatar_url":"https://avatars.githubusercontent.com/u/283842?v=3","gravatar_id":"","url":"https://api.github.com/users/nolanlawson","html_url":"https://github.com/nolanlawson","followers_url":"https://api.github.com/users/nolanlawson/followers","following_url":"https://api.github.com/users/nolanlawson/following{/other_user}","gists_url":"https://api.github.com/users/nolanlawson/gists{/gist_id}","starred_url":"https://api.github.com/users/nolanlawson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nolanlawson/subscriptions","organizations_url":"https://api.github.com/users/nolanlawson/orgs","repos_url":"https://api.github.com/users/nolanlawson/repos","events_url":"https://api.github.com/users/nolanlawson/events{/privacy}","received_events_url":"https://api.github.com/users/nolanlawson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-01-31T03:01:01Z","updated_at":"2016-01-31T05:55:09Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/pouchdb/pouchdb/pulls/4861","html_url":"https://github.com/pouchdb/pouchdb/pull/4861","diff_url":"https://github.com/pouchdb/pouchdb/pull/4861.diff","patch_url":"https://github.com/pouchdb/pouchdb/pull/4861.patch"},"body":"I've been looking into easy ways to make PouchDB faster, especially when using the in-memory adapter (because it highlights issues in the JS runtime, independent of LevelDB/IndexedDB/WebSQL stuff).\r\n\r\nUsing learnings from https://github.com/npm/npm/issues/11283#issuecomment-175246823, I ran some V8 tools on our code to see what popped up. One of the biggest sources of slowdowns is, surprisingly, the `try/catch` to do a `JSON.parse()` vs a vuvuzela parse if the JSON is too deeply recursive. `try/catch` is apparently still deoptimized in V8 (including Node v5), and I'm not sure when the Turbofan fixes are going to land (some discussion here: https://github.com/petkaantonov/bluebird/issues/848#issuecomment-154006514). So for the time being, I think it makes sense to micro-optimize this.\r\n\r\nThe commit itself might looks hacky, but this actually speeds up the tests quite a bit. Testing in Node 5.3.0 on my MBA using `LEVEL_ADAPTER=memdown time npm run test-node`, I get 150.90s before and 138.14s after (8.4% speedup). Not bad for a couple lines of code!\r\n\r\nOpening a PR because I would like to see this passing on multiple browsers before/if we merge it. The stack overflow error that this is preventing is notoriously difficult to track down, since it varies from browser to browser and depends on available memory, but if it passes in Travis I'll be satisfied."},"comment":{"url":"https://api.github.com/repos/pouchdb/pouchdb/issues/comments/177406452","html_url":"https://github.com/pouchdb/pouchdb/pull/4861#issuecomment-177406452","issue_url":"https://api.github.com/repos/pouchdb/pouchdb/issues/4861","id":177406452,"user":{"login":"nolanlawson","id":283842,"avatar_url":"https://avatars.githubusercontent.com/u/283842?v=3","gravatar_id":"","url":"https://api.github.com/users/nolanlawson","html_url":"https://github.com/nolanlawson","followers_url":"https://api.github.com/users/nolanlawson/followers","following_url":"https://api.github.com/users/nolanlawson/following{/other_user}","gists_url":"https://api.github.com/users/nolanlawson/gists{/gist_id}","starred_url":"https://api.github.com/users/nolanlawson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nolanlawson/subscriptions","organizations_url":"https://api.github.com/users/nolanlawson/orgs","repos_url":"https://api.github.com/users/nolanlawson/repos","events_url":"https://api.github.com/users/nolanlawson/events{/privacy}","received_events_url":"https://api.github.com/users/nolanlawson/received_events","type":"User","site_admin":false},"created_at":"2016-01-31T05:55:09Z","updated_at":"2016-01-31T05:55:09Z","body":"Another view:\r\n\r\n![screenshot 2016-01-31 00 54 47](https://cloud.githubusercontent.com/assets/283842/12700528/44635486-c7b5-11e5-82e7-0cc713f1d58d.png)\r\n"}}