{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/node/issues/5092","repository_url":"https://api.github.com/repos/nodejs/node","labels_url":"https://api.github.com/repos/nodejs/node/issues/5092/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/node/issues/5092/comments","events_url":"https://api.github.com/repos/nodejs/node/issues/5092/events","html_url":"https://github.com/nodejs/node/pull/5092","id":131495044,"number":5092,"title":"node: improve nextTick performance","user":{"login":"BridgeAR","id":8822573,"avatar_url":"https://avatars.githubusercontent.com/u/8822573?v=3","gravatar_id":"","url":"https://api.github.com/users/BridgeAR","html_url":"https://github.com/BridgeAR","followers_url":"https://api.github.com/users/BridgeAR/followers","following_url":"https://api.github.com/users/BridgeAR/following{/other_user}","gists_url":"https://api.github.com/users/BridgeAR/gists{/gist_id}","starred_url":"https://api.github.com/users/BridgeAR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BridgeAR/subscriptions","organizations_url":"https://api.github.com/users/BridgeAR/orgs","repos_url":"https://api.github.com/users/BridgeAR/repos","events_url":"https://api.github.com/users/BridgeAR/events{/privacy}","received_events_url":"https://api.github.com/users/BridgeAR/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-02-04T22:39:31Z","updated_at":"2016-02-04T23:03:35Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/nodejs/node/pulls/5092","html_url":"https://github.com/nodejs/node/pull/5092","diff_url":"https://github.com/nodejs/node/pull/5092.diff","patch_url":"https://github.com/nodejs/node/pull/5092.patch"},"body":"1. The try final block around the nextTick callback prevents optimizing the executing function. The try was introduced in a [commit](https://github.com/nodejs/node/commit/0109a9f90acdfdb287436676f2384f7b072fbb6a) that was [reverted](https://github.com/nodejs/node/commit/95ac576bf956055d3d5758cacbd336b53570f89f) later but without reverting the try code.\r\nThe error handling is done in C, not in JSLand, after that revert and it's therefor safe to remove the try blocks, as the queue is going to be reset anyway, no matter if the callback throws or not.\r\n\r\n2. Initializing the array with the proper argument size is faster as using a literal.\r\n\r\nThe performance gain is between 5-10% looking at the already existing nextTick benchmarks.\r\n\r\n@trevnorris pointed out that this is likely depending on https://github.com/nodejs/node/pull/4507\r\n\r\n@bnoordhuis the new [v8::Private api](https://github.com/nodejs/node/commit/924cc6c6335e58f61b04d2f41d348bd6b8be98a1) seems to change the error handling in C and after that commit the nextTick callback errors are not handled in C anymore. I'm not sure this was a intended change?"},"comment":{"url":"https://api.github.com/repos/nodejs/node/issues/comments/180094648","html_url":"https://github.com/nodejs/node/pull/5092#issuecomment-180094648","issue_url":"https://api.github.com/repos/nodejs/node/issues/5092","id":180094648,"user":{"login":"bnoordhuis","id":275871,"avatar_url":"https://avatars.githubusercontent.com/u/275871?v=3","gravatar_id":"","url":"https://api.github.com/users/bnoordhuis","html_url":"https://github.com/bnoordhuis","followers_url":"https://api.github.com/users/bnoordhuis/followers","following_url":"https://api.github.com/users/bnoordhuis/following{/other_user}","gists_url":"https://api.github.com/users/bnoordhuis/gists{/gist_id}","starred_url":"https://api.github.com/users/bnoordhuis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bnoordhuis/subscriptions","organizations_url":"https://api.github.com/users/bnoordhuis/orgs","repos_url":"https://api.github.com/users/bnoordhuis/repos","events_url":"https://api.github.com/users/bnoordhuis/events{/privacy}","received_events_url":"https://api.github.com/users/bnoordhuis/received_events","type":"User","site_admin":false},"created_at":"2016-02-04T23:03:35Z","updated_at":"2016-02-04T23:03:35Z","body":"I speculate what you're seeing is the result of removing the `tickDone()` calls that are made when an exception is raised."}}