{"action":"opened","number":7157,"pull_request":{"url":"https://api.github.com/repos/nodejs/node/pulls/7157","id":72617580,"html_url":"https://github.com/nodejs/node/pull/7157","diff_url":"https://github.com/nodejs/node/pull/7157.diff","patch_url":"https://github.com/nodejs/node/pull/7157.patch","issue_url":"https://api.github.com/repos/nodejs/node/issues/7157","number":7157,"state":"open","locked":false,"title":"buffers: speed up swap16/32, add swap64","user":{"login":"zbjornson","id":469365,"avatar_url":"https://avatars.githubusercontent.com/u/469365?v=3","gravatar_id":"","url":"https://api.github.com/users/zbjornson","html_url":"https://github.com/zbjornson","followers_url":"https://api.github.com/users/zbjornson/followers","following_url":"https://api.github.com/users/zbjornson/following{/other_user}","gists_url":"https://api.github.com/users/zbjornson/gists{/gist_id}","starred_url":"https://api.github.com/users/zbjornson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zbjornson/subscriptions","organizations_url":"https://api.github.com/users/zbjornson/orgs","repos_url":"https://api.github.com/users/zbjornson/repos","events_url":"https://api.github.com/users/zbjornson/events{/privacy}","received_events_url":"https://api.github.com/users/zbjornson/received_events","type":"User","site_admin":false},"body":"##### Checklist\r\n- [x] tests and code linting passes\r\n- [x] a test and/or benchmark is included\r\n- [x] documentation is changed or added\r\n- [x] the commit message follows commit guidelines\r\n\r\n##### Affected core subsystem(s)\r\nBuffer (swap16 and swap32 methods)\r\n\r\n##### Description of change\r\n* Speed up buffer.swap16 and swap32 by using builtins. Up to **~6x gain**. Drop transition point between JS and C++ implementations accordingly.\r\n* Fix tests: the existing C++ impl tests were testing 0-filled buffers so were always passing.\r\n* Add similar buffer.swap64 method. (Use case: working with `Float64Array`s, which I do routinely.)\r\n\r\nTested with gcc/g++ 4.8.3, clang 3.4 and MSVC 2015 (i.e. something like #4284 shouldn't happen here). Also tested the macro definitions for the `#else` and `__linux__` cases on Ubuntu. I don't know if there's a non-gcc, non-clang linux compiler we need to support; if not, then the `__linux__` case could be removed.\r\n\r\nIf/when this goes in, I plan to try using the new macros to speed up the buffer.read/write* methods.\r\n\r\n##### Benchmark Results\r\n**16 bit types**\r\n\r\n| buf len | New Native | JS | Old Native | New:Old Native |\r\n| ---: | ---: | ---: | ---: | ---: |\r\n| 4 | 5,353,146 | 9,898,898 | 5,141,171 | 1.04 |\r\n| 64 | 5,426,600 | 6,910,656 | 4,822,427 | 1.13 |\r\n| 128 | 5,315,212 | 5,492,487 | 3,941,947 | 1.35 |\r\n| 256 | 5,520,805 | 3,756,889 | 3,841,683 | 1.44 |\r\n| 512 | 5,017,195 | 2,386,928 | 3,006,634 | 1.67 |\r\n| 768 | 4,766,404 | 1,721,131 | 2,483,660 | 1.92 |\r\n| 1024 | 4,603,591 | 1,352,982 | 2,103,924 | 2.19 |\r\n| 1536 | 4,061,022 | 955,204 | 1,648,238 | 2.46 |\r\n| 2056 | 3,968,697 | 728,929 | 1,331,039 | 2.98 |\r\n| 4096 | 3,338,060 | 378,810 | 765,637 | 4.36 |\r\n| 8192 | 2,476,686 | 195,892 | 413,136 | **5.99** |\r\n\r\n**32 bit types**\r\n\r\n| buf len | New Native | JS | Old Native | New:Old Native |\r\n| ---: | ---: | ---: | ---: | ---: |\r\n| 4 | 5,464,417  | 9,933,574  | 5,348,619 | 1.02 |\r\n| 64 | 5,427,788  | 7,693,327  | 4,972,264 | 1.09 |\r\n| 128 | 5,408,238  | 5,794,946  | 4,546,107 | 1.19 |\r\n| 256 | 5,188,293  | 4,276,777  | 3,777,760 | 1.37 |\r\n| 512 | 5,022,584  | 2,792,160  | 3,068,184 | 1.64 |\r\n| 768 | 4,872,416  | 2,096,890  | 2,518,356 | 1.93 |\r\n| 1024 | 4,694,551  | 1,668,602  | 2,125,038 | 2.21 |\r\n| 1536 | 4,262,433  | 1,177,335  | 1,647,717 | 2.59 |\r\n| 2056 | 4,116,525  | 914,801  | 1,338,082 | 3.08 |\r\n| 4096 | 3,283,537  | 483,214  | 770,439 | 4.26 |\r\n| 8192 | 2,533,520  | 248,052  | 412,817 | **6.14** |\r\n\r\n**64 bit types**\r\n\r\n| buf len | New Native | JS |\r\n| ---: | ---: | ---: |\r\n| 8 | 5,640,873  | 10,097,787 |\r\n| 64 | 5,486,161  | 7,891,069 |\r\n| 128 | 5,403,555  | 6,619,267 |\r\n| 256 | 5,296,904  | 4,673,973 |\r\n| 512 | 5,124,202  | 3,098,105 |\r\n| 768 | 4,522,887  | 2,334,265 |\r\n| 1024 | 4,605,491  | 1,867,182 |\r\n| 1536 | 4,290,413  | 1,356,988 |\r\n| 2056 | 3,972,674  | 1,054,184 |\r\n| 4096 | 3,370,964  | 562,251 |\r\n| 8192 | 2,478,062  | 288,762 |","created_at":"2016-06-05T01:13:32Z","updated_at":"2016-06-05T01:13:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nodejs/node/pulls/7157/commits","review_comments_url":"https://api.github.com/repos/nodejs/node/pulls/7157/comments","review_comment_url":"https://api.github.com/repos/nodejs/node/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nodejs/node/issues/7157/comments","statuses_url":"https://api.github.com/repos/nodejs/node/statuses/81556e8a8b002ec776b3cbb3d479e277d03a6579","head":{"label":"zbjornson:buffer-swap-perf","ref":"buffer-swap-perf","sha":"81556e8a8b002ec776b3cbb3d479e277d03a6579","user":{"login":"zbjornson","id":469365,"avatar_url":"https://avatars.githubusercontent.com/u/469365?v=3","gravatar_id":"","url":"https://api.github.com/users/zbjornson","html_url":"https://github.com/zbjornson","followers_url":"https://api.github.com/users/zbjornson/followers","following_url":"https://api.github.com/users/zbjornson/following{/other_user}","gists_url":"https://api.github.com/users/zbjornson/gists{/gist_id}","starred_url":"https://api.github.com/users/zbjornson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zbjornson/subscriptions","organizations_url":"https://api.github.com/users/zbjornson/orgs","repos_url":"https://api.github.com/users/zbjornson/repos","events_url":"https://api.github.com/users/zbjornson/events{/privacy}","received_events_url":"https://api.github.com/users/zbjornson/received_events","type":"User","site_admin":false},"repo":{"id":60315003,"name":"node","full_name":"zbjornson/node","owner":{"login":"zbjornson","id":469365,"avatar_url":"https://avatars.githubusercontent.com/u/469365?v=3","gravatar_id":"","url":"https://api.github.com/users/zbjornson","html_url":"https://github.com/zbjornson","followers_url":"https://api.github.com/users/zbjornson/followers","following_url":"https://api.github.com/users/zbjornson/following{/other_user}","gists_url":"https://api.github.com/users/zbjornson/gists{/gist_id}","starred_url":"https://api.github.com/users/zbjornson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zbjornson/subscriptions","organizations_url":"https://api.github.com/users/zbjornson/orgs","repos_url":"https://api.github.com/users/zbjornson/repos","events_url":"https://api.github.com/users/zbjornson/events{/privacy}","received_events_url":"https://api.github.com/users/zbjornson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zbjornson/node","description":"Node.js JavaScript runtime :sparkles::turtle::rocket::sparkles:","fork":true,"url":"https://api.github.com/repos/zbjornson/node","forks_url":"https://api.github.com/repos/zbjornson/node/forks","keys_url":"https://api.github.com/repos/zbjornson/node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zbjornson/node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zbjornson/node/teams","hooks_url":"https://api.github.com/repos/zbjornson/node/hooks","issue_events_url":"https://api.github.com/repos/zbjornson/node/issues/events{/number}","events_url":"https://api.github.com/repos/zbjornson/node/events","assignees_url":"https://api.github.com/repos/zbjornson/node/assignees{/user}","branches_url":"https://api.github.com/repos/zbjornson/node/branches{/branch}","tags_url":"https://api.github.com/repos/zbjornson/node/tags","blobs_url":"https://api.github.com/repos/zbjornson/node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zbjornson/node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zbjornson/node/git/refs{/sha}","trees_url":"https://api.github.com/repos/zbjornson/node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zbjornson/node/statuses/{sha}","languages_url":"https://api.github.com/repos/zbjornson/node/languages","stargazers_url":"https://api.github.com/repos/zbjornson/node/stargazers","contributors_url":"https://api.github.com/repos/zbjornson/node/contributors","subscribers_url":"https://api.github.com/repos/zbjornson/node/subscribers","subscription_url":"https://api.github.com/repos/zbjornson/node/subscription","commits_url":"https://api.github.com/repos/zbjornson/node/commits{/sha}","git_commits_url":"https://api.github.com/repos/zbjornson/node/git/commits{/sha}","comments_url":"https://api.github.com/repos/zbjornson/node/comments{/number}","issue_comment_url":"https://api.github.com/repos/zbjornson/node/issues/comments{/number}","contents_url":"https://api.github.com/repos/zbjornson/node/contents/{+path}","compare_url":"https://api.github.com/repos/zbjornson/node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zbjornson/node/merges","archive_url":"https://api.github.com/repos/zbjornson/node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zbjornson/node/downloads","issues_url":"https://api.github.com/repos/zbjornson/node/issues{/number}","pulls_url":"https://api.github.com/repos/zbjornson/node/pulls{/number}","milestones_url":"https://api.github.com/repos/zbjornson/node/milestones{/number}","notifications_url":"https://api.github.com/repos/zbjornson/node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zbjornson/node/labels{/name}","releases_url":"https://api.github.com/repos/zbjornson/node/releases{/id}","deployments_url":"https://api.github.com/repos/zbjornson/node/deployments","created_at":"2016-06-03T03:17:08Z","updated_at":"2016-06-03T03:17:24Z","pushed_at":"2016-06-05T00:53:04Z","git_url":"git://github.com/zbjornson/node.git","ssh_url":"git@github.com:zbjornson/node.git","clone_url":"https://github.com/zbjornson/node.git","svn_url":"https://github.com/zbjornson/node","homepage":"https://nodejs.org","size":219899,"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":"de0aa23ad71e63c90be947f79b547f7c303ce7b8","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}","deployments_url":"https://api.github.com/repos/nodejs/node/deployments","created_at":"2014-11-26T19:57:11Z","updated_at":"2016-06-05T00:40:39Z","pushed_at":"2016-06-04T21:25:23Z","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":281317,"stargazers_count":23804,"watchers_count":23804,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3447,"mirror_url":null,"open_issues_count":706,"forks":3447,"open_issues":706,"watchers":23804,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nodejs/node/pulls/7157"},"html":{"href":"https://github.com/nodejs/node/pull/7157"},"issue":{"href":"https://api.github.com/repos/nodejs/node/issues/7157"},"comments":{"href":"https://api.github.com/repos/nodejs/node/issues/7157/comments"},"review_comments":{"href":"https://api.github.com/repos/nodejs/node/pulls/7157/comments"},"review_comment":{"href":"https://api.github.com/repos/nodejs/node/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nodejs/node/pulls/7157/commits"},"statuses":{"href":"https://api.github.com/repos/nodejs/node/statuses/81556e8a8b002ec776b3cbb3d479e277d03a6579"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":197,"deletions":42,"changed_files":5}}
{"actor":{"display_login":"zbjornson"}}