{"action":"created","comment":{"url":"https://api.github.com/repos/nodejs/node/pulls/comments/41854033","id":41854033,"diff_hunk":"@@ -894,6 +906,12 @@ Socket.prototype.connect = function(options, cb) {\n   self._connecting = true;\n   self.writable = true;\n \n+  // Cork then uncork upon connecting.\n+  this.cork();\n+  this.once('connect', function() {\n+    this.uncork();\n+  });","path":"lib/net.js","position":95,"original_position":95,"commit_id":"faa1eba4eced6c81a61e0f07b8cc984d5d2cf4c3","original_commit_id":"faa1eba4eced6c81a61e0f07b8cc984d5d2cf4c3","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},"body":"Is there a reason you cork eagerly here instead of lazily in `Socket#_writeGeneric()`?  The change LGTM, just wondering.","created_at":"2015-10-13T11:22:38Z","updated_at":"2015-10-13T11:22:38Z","html_url":"https://github.com/nodejs/node/pull/2960#discussion_r41854033","pull_request_url":"https://api.github.com/repos/nodejs/node/pulls/2960","_links":{"self":{"href":"https://api.github.com/repos/nodejs/node/pulls/comments/41854033"},"html":{"href":"https://github.com/nodejs/node/pull/2960#discussion_r41854033"},"pull_request":{"href":"https://api.github.com/repos/nodejs/node/pulls/2960"}}},"pull_request":{"url":"https://api.github.com/repos/nodejs/node/pulls/2960","id":45464832,"html_url":"https://github.com/nodejs/node/pull/2960","diff_url":"https://github.com/nodejs/node/pull/2960.diff","patch_url":"https://github.com/nodejs/node/pull/2960.patch","issue_url":"https://api.github.com/repos/nodejs/node/issues/2960","number":2960,"state":"open","locked":false,"title":"net: write syscall optimization and a bytesWritten bug fix","user":{"login":"brendanashworth","id":3038254,"avatar_url":"https://avatars.githubusercontent.com/u/3038254?v=3","gravatar_id":"","url":"https://api.github.com/users/brendanashworth","html_url":"https://github.com/brendanashworth","followers_url":"https://api.github.com/users/brendanashworth/followers","following_url":"https://api.github.com/users/brendanashworth/following{/other_user}","gists_url":"https://api.github.com/users/brendanashworth/gists{/gist_id}","starred_url":"https://api.github.com/users/brendanashworth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendanashworth/subscriptions","organizations_url":"https://api.github.com/users/brendanashworth/orgs","repos_url":"https://api.github.com/users/brendanashworth/repos","events_url":"https://api.github.com/users/brendanashworth/events{/privacy}","received_events_url":"https://api.github.com/users/brendanashworth/received_events","type":"User","site_admin":false},"body":"This pull request contains two changes to net: one that uses `.cork()`/`.uncork()` on a socket as it is connecting, and the other to fix the value of `.bytesWritten` while a socket is connecting and a `._writev` call is issued.\r\n\r\n#### `.cork()` / `.uncork()`\r\nBy using these two values on the Writable stream of the socket while it is connecting, we can avoid the common stream-ism of a single buffered `._write`, then a larger `._writev` following it. This change merges multiple writes to a connecting stream into a single `writev` call, rather than two calls as before. [Here](https://gist.github.com/brendanashworth/5b560ffdef7ee0045c9b) is an explanation gist.\r\n\r\n#### `.bytesWritten` fix\r\nAs found by reading over the code base, if a `writev` call is issued and cached (while connecting), `_pendingData` will be an array. Because there was no special functionality for this, `Buffer.byteLength` coerced the array to a string and returned the byte length of that. This fixes that bug and adds a regression test.","created_at":"2015-09-19T00:13:07Z","updated_at":"2015-10-13T11:22:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8af002198082471ceb594eb22b2e33e882749d1b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nodejs/node/pulls/2960/commits","review_comments_url":"https://api.github.com/repos/nodejs/node/pulls/2960/comments","review_comment_url":"https://api.github.com/repos/nodejs/node/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nodejs/node/issues/2960/comments","statuses_url":"https://api.github.com/repos/nodejs/node/statuses/faa1eba4eced6c81a61e0f07b8cc984d5d2cf4c3","head":{"label":"brendanashworth:new/net-socket-cork","ref":"new/net-socket-cork","sha":"faa1eba4eced6c81a61e0f07b8cc984d5d2cf4c3","user":{"login":"brendanashworth","id":3038254,"avatar_url":"https://avatars.githubusercontent.com/u/3038254?v=3","gravatar_id":"","url":"https://api.github.com/users/brendanashworth","html_url":"https://github.com/brendanashworth","followers_url":"https://api.github.com/users/brendanashworth/followers","following_url":"https://api.github.com/users/brendanashworth/following{/other_user}","gists_url":"https://api.github.com/users/brendanashworth/gists{/gist_id}","starred_url":"https://api.github.com/users/brendanashworth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendanashworth/subscriptions","organizations_url":"https://api.github.com/users/brendanashworth/orgs","repos_url":"https://api.github.com/users/brendanashworth/repos","events_url":"https://api.github.com/users/brendanashworth/events{/privacy}","received_events_url":"https://api.github.com/users/brendanashworth/received_events","type":"User","site_admin":false},"repo":{"id":27578495,"name":"io.js","full_name":"brendanashworth/io.js","owner":{"login":"brendanashworth","id":3038254,"avatar_url":"https://avatars.githubusercontent.com/u/3038254?v=3","gravatar_id":"","url":"https://api.github.com/users/brendanashworth","html_url":"https://github.com/brendanashworth","followers_url":"https://api.github.com/users/brendanashworth/followers","following_url":"https://api.github.com/users/brendanashworth/following{/other_user}","gists_url":"https://api.github.com/users/brendanashworth/gists{/gist_id}","starred_url":"https://api.github.com/users/brendanashworth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendanashworth/subscriptions","organizations_url":"https://api.github.com/users/brendanashworth/orgs","repos_url":"https://api.github.com/users/brendanashworth/repos","events_url":"https://api.github.com/users/brendanashworth/events{/privacy}","received_events_url":"https://api.github.com/users/brendanashworth/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/brendanashworth/io.js","description":"Evented IO for V8 JavaScript","fork":true,"url":"https://api.github.com/repos/brendanashworth/io.js","forks_url":"https://api.github.com/repos/brendanashworth/io.js/forks","keys_url":"https://api.github.com/repos/brendanashworth/io.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/brendanashworth/io.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/brendanashworth/io.js/teams","hooks_url":"https://api.github.com/repos/brendanashworth/io.js/hooks","issue_events_url":"https://api.github.com/repos/brendanashworth/io.js/issues/events{/number}","events_url":"https://api.github.com/repos/brendanashworth/io.js/events","assignees_url":"https://api.github.com/repos/brendanashworth/io.js/assignees{/user}","branches_url":"https://api.github.com/repos/brendanashworth/io.js/branches{/branch}","tags_url":"https://api.github.com/repos/brendanashworth/io.js/tags","blobs_url":"https://api.github.com/repos/brendanashworth/io.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/brendanashworth/io.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/brendanashworth/io.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/brendanashworth/io.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/brendanashworth/io.js/statuses/{sha}","languages_url":"https://api.github.com/repos/brendanashworth/io.js/languages","stargazers_url":"https://api.github.com/repos/brendanashworth/io.js/stargazers","contributors_url":"https://api.github.com/repos/brendanashworth/io.js/contributors","subscribers_url":"https://api.github.com/repos/brendanashworth/io.js/subscribers","subscription_url":"https://api.github.com/repos/brendanashworth/io.js/subscription","commits_url":"https://api.github.com/repos/brendanashworth/io.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/brendanashworth/io.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/brendanashworth/io.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/brendanashworth/io.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/brendanashworth/io.js/contents/{+path}","compare_url":"https://api.github.com/repos/brendanashworth/io.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/brendanashworth/io.js/merges","archive_url":"https://api.github.com/repos/brendanashworth/io.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/brendanashworth/io.js/downloads","issues_url":"https://api.github.com/repos/brendanashworth/io.js/issues{/number}","pulls_url":"https://api.github.com/repos/brendanashworth/io.js/pulls{/number}","milestones_url":"https://api.github.com/repos/brendanashworth/io.js/milestones{/number}","notifications_url":"https://api.github.com/repos/brendanashworth/io.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/brendanashworth/io.js/labels{/name}","releases_url":"https://api.github.com/repos/brendanashworth/io.js/releases{/id}","created_at":"2014-12-05T06:43:32Z","updated_at":"2015-05-05T00:37:56Z","pushed_at":"2015-09-28T05:55:38Z","git_url":"git://github.com/brendanashworth/io.js.git","ssh_url":"git@github.com:brendanashworth/io.js.git","clone_url":"https://github.com/brendanashworth/io.js.git","svn_url":"https://github.com/brendanashworth/io.js","homepage":null,"size":144404,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"nodejs:master","ref":"master","sha":"a7130245796dc6a422063af2b0b55ca1120a9dc9","user":{"login":"nodejs","id":9950313,"avatar_url":"https://avatars.githubusercontent.com/u/9950313?v=3","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"repo":{"id":27193779,"name":"node","full_name":"nodejs/node","owner":{"login":"nodejs","id":9950313,"avatar_url":"https://avatars.githubusercontent.com/u/9950313?v=3","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nodejs/node","description":"Node.js JavaScript runtime :sparkles::turtle::rocket::sparkles:","fork":false,"url":"https://api.github.com/repos/nodejs/node","forks_url":"https://api.github.com/repos/nodejs/node/forks","keys_url":"https://api.github.com/repos/nodejs/node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nodejs/node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nodejs/node/teams","hooks_url":"https://api.github.com/repos/nodejs/node/hooks","issue_events_url":"https://api.github.com/repos/nodejs/node/issues/events{/number}","events_url":"https://api.github.com/repos/nodejs/node/events","assignees_url":"https://api.github.com/repos/nodejs/node/assignees{/user}","branches_url":"https://api.github.com/repos/nodejs/node/branches{/branch}","tags_url":"https://api.github.com/repos/nodejs/node/tags","blobs_url":"https://api.github.com/repos/nodejs/node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nodejs/node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nodejs/node/git/refs{/sha}","trees_url":"https://api.github.com/repos/nodejs/node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nodejs/node/statuses/{sha}","languages_url":"https://api.github.com/repos/nodejs/node/languages","stargazers_url":"https://api.github.com/repos/nodejs/node/stargazers","contributors_url":"https://api.github.com/repos/nodejs/node/contributors","subscribers_url":"https://api.github.com/repos/nodejs/node/subscribers","subscription_url":"https://api.github.com/repos/nodejs/node/subscription","commits_url":"https://api.github.com/repos/nodejs/node/commits{/sha}","git_commits_url":"https://api.github.com/repos/nodejs/node/git/commits{/sha}","comments_url":"https://api.github.com/repos/nodejs/node/comments{/number}","issue_comment_url":"https://api.github.com/repos/nodejs/node/issues/comments{/number}","contents_url":"https://api.github.com/repos/nodejs/node/contents/{+path}","compare_url":"https://api.github.com/repos/nodejs/node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nodejs/node/merges","archive_url":"https://api.github.com/repos/nodejs/node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nodejs/node/downloads","issues_url":"https://api.github.com/repos/nodejs/node/issues{/number}","pulls_url":"https://api.github.com/repos/nodejs/node/pulls{/number}","milestones_url":"https://api.github.com/repos/nodejs/node/milestones{/number}","notifications_url":"https://api.github.com/repos/nodejs/node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nodejs/node/labels{/name}","releases_url":"https://api.github.com/repos/nodejs/node/releases{/id}","created_at":"2014-11-26T19:57:11Z","updated_at":"2015-10-13T10:27:53Z","pushed_at":"2015-10-13T11:11:14Z","git_url":"git://github.com/nodejs/node.git","ssh_url":"git@github.com:nodejs/node.git","clone_url":"https://github.com/nodejs/node.git","svn_url":"https://github.com/nodejs/node","homepage":"https://nodejs.org","size":367154,"stargazers_count":16077,"watchers_count":16077,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1531,"mirror_url":null,"open_issues_count":516,"forks":1531,"open_issues":516,"watchers":16077,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nodejs/node/pulls/2960"},"html":{"href":"https://github.com/nodejs/node/pull/2960"},"issue":{"href":"https://api.github.com/repos/nodejs/node/issues/2960"},"comments":{"href":"https://api.github.com/repos/nodejs/node/issues/2960/comments"},"review_comments":{"href":"https://api.github.com/repos/nodejs/node/pulls/2960/comments"},"review_comment":{"href":"https://api.github.com/repos/nodejs/node/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nodejs/node/pulls/2960/commits"},"statuses":{"href":"https://api.github.com/repos/nodejs/node/statuses/faa1eba4eced6c81a61e0f07b8cc984d5d2cf4c3"}}}}