{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/node/issues/6082","repository_url":"https://api.github.com/repos/nodejs/node","labels_url":"https://api.github.com/repos/nodejs/node/issues/6082/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/node/issues/6082/comments","events_url":"https://api.github.com/repos/nodejs/node/issues/6082/events","html_url":"https://github.com/nodejs/node/pull/6082","id":146401567,"number":6082,"title":"async_wrap,lib: Firing async-wrap callbacks for next-tick callbacks","user":{"login":"mike-kaufman","id":8702326,"avatar_url":"https://avatars.githubusercontent.com/u/8702326?v=3","gravatar_id":"","url":"https://api.github.com/users/mike-kaufman","html_url":"https://github.com/mike-kaufman","followers_url":"https://api.github.com/users/mike-kaufman/followers","following_url":"https://api.github.com/users/mike-kaufman/following{/other_user}","gists_url":"https://api.github.com/users/mike-kaufman/gists{/gist_id}","starred_url":"https://api.github.com/users/mike-kaufman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mike-kaufman/subscriptions","organizations_url":"https://api.github.com/users/mike-kaufman/orgs","repos_url":"https://api.github.com/users/mike-kaufman/repos","events_url":"https://api.github.com/users/mike-kaufman/events{/privacy}","received_events_url":"https://api.github.com/users/mike-kaufman/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nodejs/node/labels/async_wrap","name":"async_wrap","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2016-04-06T18:50:20Z","updated_at":"2016-04-15T00:06:18Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/nodejs/node/pulls/6082","html_url":"https://github.com/nodejs/node/pull/6082","diff_url":"https://github.com/nodejs/node/pull/6082.diff","patch_url":"https://github.com/nodejs/node/pull/6082.patch"},"body":"\r\n##### Checklist\r\n\r\n- [x] tests and code linting passes\r\n- [x] a test and/or benchmark is included\r\n- [ ] documentation is changed or added\r\n- [x] the commit message follows commit guidelines\r\n\r\nCaveats:\r\n  - seeing the following test failures on windows that occur without my changes:\r\n    - parallel/test-path (fix is part of PR #6067)\r\n    - parallel/test-tls-server-verify - intermittent failures without my changes.\r\n    - addons/load-long-path/test.  See error message \"The data area passed to a system call is too small\".  I'll need to dig a bit more to see if this repros without my changes. \r\n    -   test\\sequential\\test-regress-GH-746.js - this times out intermittently without my changes.\r\n  - I'm not sure if there are docs that need updated here.  Please let me know\r\n  - I'm not sure if there are relevant benchmarks that I should run.  Please let me know.\r\n\r\n\r\n##### Affected core subsystem(s)\r\n\r\nasync_wrap;lib\r\n\r\n\r\n##### Description of change\r\n\r\nThis change updates nextTick() callback processing to call back into\r\nthe node runtime to notify the runtime of async state transitions.\r\nCurrently, the runtime will track the active async ID and fire any\r\nregistered async-wrap callbacks. This gives async-wrap consistent user\r\nsemantics for nextTick() callbacks.\r\n\r\nI anticipate some concerns around impact to perf. Rough measurements\r\nshow an approximate 2x increase in time to process 1,000,000 nextTick()\r\ncallbacks.  These went from an average of 1094 ms per million\r\nnextTick() callbacks to 2133 ms per million with the changes in this PR.\r\n\r\nI'm open to alternative suggestions around implementation here. :) It's\r\nnot lost on me that the implementation of next_tick.js is making an\r\neffort to minimize transitions from JS to the runtime, and this change\r\nincreases those transitions by a factor of three. One of the goals\r\nhere was to have basic entry-points for javascript code to notify the\r\nruntime of async transitions (namely, \"enqueue\", \"start\", and \"end\").\r\nThis allows a future where async call graph information can be tracked\r\nby the runtime and eliminates a number of cases where users will\r\nrequire the async-wrap callbacks.  For example, continuation-local\r\nstorage can be implemented on such an API, without callbacks, assuming\r\neach node in the graph contains a tuple of (unique ID, parent ID,\r\npending child callback count, state), and where state is one of\r\nenqueued, running, or completed."},"comment":{"url":"https://api.github.com/repos/nodejs/node/issues/comments/210211498","html_url":"https://github.com/nodejs/node/pull/6082#issuecomment-210211498","issue_url":"https://api.github.com/repos/nodejs/node/issues/6082","id":210211498,"user":{"login":"Fishrock123","id":1093990,"avatar_url":"https://avatars.githubusercontent.com/u/1093990?v=3","gravatar_id":"","url":"https://api.github.com/users/Fishrock123","html_url":"https://github.com/Fishrock123","followers_url":"https://api.github.com/users/Fishrock123/followers","following_url":"https://api.github.com/users/Fishrock123/following{/other_user}","gists_url":"https://api.github.com/users/Fishrock123/gists{/gist_id}","starred_url":"https://api.github.com/users/Fishrock123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fishrock123/subscriptions","organizations_url":"https://api.github.com/users/Fishrock123/orgs","repos_url":"https://api.github.com/users/Fishrock123/repos","events_url":"https://api.github.com/users/Fishrock123/events{/privacy}","received_events_url":"https://api.github.com/users/Fishrock123/received_events","type":"User","site_admin":false},"created_at":"2016-04-15T00:06:18Z","updated_at":"2016-04-15T00:06:18Z","body":"The c++ code linting here doesn't _actually_ pass.\r\n\r\nI'm guessing you are running on windows, since our vcbuild file isn't able to invoke our cpplint.\r\n\r\nHere's the errors:\r\n```\r\nsrc/async-wrap.cc:123:  Lines should be <= 80 characters long  [whitespace/line_length] [2]\r\nsrc/async-wrap.cc:129:  Lines should be <= 80 characters long  [whitespace/line_length] [2]\r\nsrc/async-wrap.cc:141:  { should almost always be at the end of the previous line  [whitespace/braces] [4]\r\nsrc/async-wrap.cc:147:  Blank line at the start of a code block.  Is this needed?  [whitespace/blank_line] [2]\r\nsrc/async-wrap.cc:191:  Lines should be <= 80 characters long  [whitespace/line_length] [2]\r\nsrc/async-wrap.cc:194:  Lines should be <= 80 characters long  [whitespace/line_length] [2]\r\nsrc/async-wrap.cc:205:  Using C-style cast.  Use reinterpret_cast<AsyncWrap*>(...) instead  [readability/casting] [4]\r\nsrc/async-wrap.cc:216:  { should almost always be at the end of the previous line  [whitespace/braces] [4]\r\nsrc/async-wrap.cc:219:  Blank line at the start of a code block.  Is this needed?  [whitespace/blank_line] [2]\r\nsrc/async-wrap.cc:245:  { should almost always be at the end of the previous line  [whitespace/braces] [4]\r\nsrc/async-wrap.cc:270:  Lines should very rarely be longer than 100 characters  [whitespace/line_length] [4]\r\nsrc/async-wrap.cc:271:  Blank line at the start of a code block.  Is this needed?  [whitespace/blank_line] [2]\r\nsrc/async-wrap.cc:295:  Lines should be <= 80 characters long  [whitespace/line_length] [2]\r\nsrc/async-wrap.cc:296:  Lines should be <= 80 characters long  [whitespace/line_length] [2]\r\nsrc/async-wrap.cc:299:  Lines should very rarely be longer than 100 characters  [whitespace/line_length] [4]\r\nsrc/async-wrap.cc:300:  Blank line at the start of a code block.  Is this needed?  [whitespace/blank_line] [2]\r\nsrc/async-wrap.cc:308:  Lines should be <= 80 characters long  [whitespace/line_length] [2]\r\nsrc/async-wrap.cc:315:  Blank line at the end of a code block.  Is this needed?  [whitespace/blank_line] [3]\r\nsrc/async-wrap.cc:435:  Lines should be <= 80 characters long  [whitespace/line_length] [2]\r\nsrc/async-wrap.cc:436:  Line ends in whitespace. Consider deleting these extra spaces.  [whitespace/end_of_line] [4]\r\nsrc/async-wrap-inl.h:28:  Lines should be <= 80 characters long  [whitespace/line_length] [2]\r\nsrc/async-wrap-inl.h:36:  Lines should very rarely be longer than 100 characters  [whitespace/line_length] [4]\r\nsrc/async-wrap.h:51:  Lines should very rarely be longer than 100 characters  [whitespace/line_length] [4]\r\nsrc/async-wrap.h:51:  Missing space after ,  [whitespace/comma] [3]\r\nsrc/async-wrap.h:52:  Lines should very rarely be longer than 100 characters  [whitespace/line_length] [4]\r\nsrc/async-wrap.h:53:  Lines should very rarely be longer than 100 characters  [whitespace/line_length] [4]\r\nsrc/async-wrap.h:54:  Lines should very rarely be longer than 100 characters  [whitespace/line_length] [4]\r\n```"}}