{"action":"created","comment":{"url":"https://api.github.com/repos/netty/netty/pulls/comments/28264939","id":28264939,"diff_hunk":"@@ -311,6 +318,37 @@ static void copyMemory(Object src, long srcOffset, Object dst, long dstOffset, l\n         }\n     }\n \n+    static boolean equals(final byte[] bytes1, final byte[] bytes2) {\n+        if (bytes1.length != bytes2.length) {\n+            return false;\n+        }\n+        if (bytes1.length == 0) {\n+            return true;\n+        }\n+        int remainingBytes = bytes1.length & 7;\n+        for (int i = bytes1.length - 8; i >= remainingBytes; i -= 8) {\n+            final long word1 = UNSAFE.getLong(bytes1, ARRAY_BASE_OFFSET + i);","path":"common/src/main/java/io/netty/util/internal/PlatformDependent0.java","position":53,"original_position":53,"commit_id":"95af4d2e38951bd6f2259bdc693b3078c488515a","original_commit_id":"bcd4643d20546b90d90b2121041a95b834ad6333","user":{"login":"Scottmitch","id":7562868,"avatar_url":"https://avatars.githubusercontent.com/u/7562868?v=3","gravatar_id":"","url":"https://api.github.com/users/Scottmitch","html_url":"https://github.com/Scottmitch","followers_url":"https://api.github.com/users/Scottmitch/followers","following_url":"https://api.github.com/users/Scottmitch/following{/other_user}","gists_url":"https://api.github.com/users/Scottmitch/gists{/gist_id}","starred_url":"https://api.github.com/users/Scottmitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Scottmitch/subscriptions","organizations_url":"https://api.github.com/users/Scottmitch/orgs","repos_url":"https://api.github.com/users/Scottmitch/repos","events_url":"https://api.github.com/users/Scottmitch/events{/privacy}","received_events_url":"https://api.github.com/users/Scottmitch/received_events","type":"User","site_admin":false},"body":"Agreed that it may be a small thing but if we are trying to communicate conceptual meaning of values with local variable then can we use a comment?  Comments are 0 work for JIT :)  Things are pretty self contained here and the purpose for this method is to optimize an operation.  BTW 169 lines of byte code with inline suggestions vs 192 as is without any changes.","created_at":"2015-04-13T18:30:35Z","updated_at":"2015-04-13T18:30:35Z","html_url":"https://github.com/netty/netty/pull/3626#discussion_r28264939","pull_request_url":"https://api.github.com/repos/netty/netty/pulls/3626","_links":{"self":{"href":"https://api.github.com/repos/netty/netty/pulls/comments/28264939"},"html":{"href":"https://github.com/netty/netty/pull/3626#discussion_r28264939"},"pull_request":{"href":"https://api.github.com/repos/netty/netty/pulls/3626"}}},"pull_request":{"url":"https://api.github.com/repos/netty/netty/pulls/3626","id":33182121,"html_url":"https://github.com/netty/netty/pull/3626","diff_url":"https://github.com/netty/netty/pull/3626.diff","patch_url":"https://github.com/netty/netty/pull/3626.patch","issue_url":"https://api.github.com/repos/netty/netty/issues/3626","number":3626,"state":"open","locked":false,"title":"Improve performance of AsciiString.equals(Object).","user":{"login":"buchgr","id":1388179,"avatar_url":"https://avatars.githubusercontent.com/u/1388179?v=3","gravatar_id":"","url":"https://api.github.com/users/buchgr","html_url":"https://github.com/buchgr","followers_url":"https://api.github.com/users/buchgr/followers","following_url":"https://api.github.com/users/buchgr/following{/other_user}","gists_url":"https://api.github.com/users/buchgr/gists{/gist_id}","starred_url":"https://api.github.com/users/buchgr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/buchgr/subscriptions","organizations_url":"https://api.github.com/users/buchgr/orgs","repos_url":"https://api.github.com/users/buchgr/repos","events_url":"https://api.github.com/users/buchgr/events{/privacy}","received_events_url":"https://api.github.com/users/buchgr/received_events","type":"User","site_admin":false},"body":"Motivation:\r\n\r\nThe current implementation does byte by byte comparison, which we have seen\r\ncan be a performance bottleneck when the AsciiString is used as the key in\r\na Map.\r\n\r\nModifications:\r\n\r\nUse sun.misc.Unsafe (on supporting platforms) to compare up to eight bytes at a time\r\nand get closer to the performance of String.equals(Object).\r\n\r\nResult:\r\n\r\nSignificant improvement (2x - 6x) in performance over the current implementation.\r\n```\r\nBenchmark                                             (size)   Mode   Samples        Score  Score error    Units\r\ni.n.m.i.PlatformDependentBenchmark.arraysBytesEqual       10  thrpt        10 118843477.518 2347259.347    ops/s\r\ni.n.m.i.PlatformDependentBenchmark.arraysBytesEqual       50  thrpt        10 43910319.773   198376.996    ops/s\r\ni.n.m.i.PlatformDependentBenchmark.arraysBytesEqual      100  thrpt        10 26339969.001   159599.252    ops/s\r\ni.n.m.i.PlatformDependentBenchmark.arraysBytesEqual     1000  thrpt        10  2873119.030    20779.056    ops/s\r\ni.n.m.i.PlatformDependentBenchmark.arraysBytesEqual    10000  thrpt        10   306370.450     1933.303    ops/s\r\ni.n.m.i.PlatformDependentBenchmark.arraysBytesEqual   100000  thrpt        10    25750.415      108.391    ops/s\r\ni.n.m.i.PlatformDependentBenchmark.unsafeBytesEqual       10  thrpt        10 248077563.510  635320.093    ops/s\r\ni.n.m.i.PlatformDependentBenchmark.unsafeBytesEqual       50  thrpt        10 128198943.138  614827.548    ops/s\r\ni.n.m.i.PlatformDependentBenchmark.unsafeBytesEqual      100  thrpt        10 86195621.349  1063959.307    ops/s\r\ni.n.m.i.PlatformDependentBenchmark.unsafeBytesEqual     1000  thrpt        10 16920264.598    61615.365    ops/s\r\ni.n.m.i.PlatformDependentBenchmark.unsafeBytesEqual    10000  thrpt        10  1687454.747     6367.602    ops/s\r\ni.n.m.i.PlatformDependentBenchmark.unsafeBytesEqual   100000  thrpt        10   153717.851      586.916    ops/s\\\r\n```","created_at":"2015-04-13T16:57:57Z","updated_at":"2015-04-13T18:30:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"da397e879fcb71d9d934d12dc8f6f0b0e43d33b3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/netty/netty/pulls/3626/commits","review_comments_url":"https://api.github.com/repos/netty/netty/pulls/3626/comments","review_comment_url":"https://api.github.com/repos/netty/netty/pulls/comments{/number}","comments_url":"https://api.github.com/repos/netty/netty/issues/3626/comments","statuses_url":"https://api.github.com/repos/netty/netty/statuses/95af4d2e38951bd6f2259bdc693b3078c488515a","head":{"label":"buchgr:waaazzup","ref":"waaazzup","sha":"95af4d2e38951bd6f2259bdc693b3078c488515a","user":{"login":"buchgr","id":1388179,"avatar_url":"https://avatars.githubusercontent.com/u/1388179?v=3","gravatar_id":"","url":"https://api.github.com/users/buchgr","html_url":"https://github.com/buchgr","followers_url":"https://api.github.com/users/buchgr/followers","following_url":"https://api.github.com/users/buchgr/following{/other_user}","gists_url":"https://api.github.com/users/buchgr/gists{/gist_id}","starred_url":"https://api.github.com/users/buchgr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/buchgr/subscriptions","organizations_url":"https://api.github.com/users/buchgr/orgs","repos_url":"https://api.github.com/users/buchgr/repos","events_url":"https://api.github.com/users/buchgr/events{/privacy}","received_events_url":"https://api.github.com/users/buchgr/received_events","type":"User","site_admin":false},"repo":{"id":17233219,"name":"netty","full_name":"buchgr/netty","owner":{"login":"buchgr","id":1388179,"avatar_url":"https://avatars.githubusercontent.com/u/1388179?v=3","gravatar_id":"","url":"https://api.github.com/users/buchgr","html_url":"https://github.com/buchgr","followers_url":"https://api.github.com/users/buchgr/followers","following_url":"https://api.github.com/users/buchgr/following{/other_user}","gists_url":"https://api.github.com/users/buchgr/gists{/gist_id}","starred_url":"https://api.github.com/users/buchgr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/buchgr/subscriptions","organizations_url":"https://api.github.com/users/buchgr/orgs","repos_url":"https://api.github.com/users/buchgr/repos","events_url":"https://api.github.com/users/buchgr/events{/privacy}","received_events_url":"https://api.github.com/users/buchgr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/buchgr/netty","description":"Netty project - an event-driven asynchronous network application framework","fork":true,"url":"https://api.github.com/repos/buchgr/netty","forks_url":"https://api.github.com/repos/buchgr/netty/forks","keys_url":"https://api.github.com/repos/buchgr/netty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/buchgr/netty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/buchgr/netty/teams","hooks_url":"https://api.github.com/repos/buchgr/netty/hooks","issue_events_url":"https://api.github.com/repos/buchgr/netty/issues/events{/number}","events_url":"https://api.github.com/repos/buchgr/netty/events","assignees_url":"https://api.github.com/repos/buchgr/netty/assignees{/user}","branches_url":"https://api.github.com/repos/buchgr/netty/branches{/branch}","tags_url":"https://api.github.com/repos/buchgr/netty/tags","blobs_url":"https://api.github.com/repos/buchgr/netty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/buchgr/netty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/buchgr/netty/git/refs{/sha}","trees_url":"https://api.github.com/repos/buchgr/netty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/buchgr/netty/statuses/{sha}","languages_url":"https://api.github.com/repos/buchgr/netty/languages","stargazers_url":"https://api.github.com/repos/buchgr/netty/stargazers","contributors_url":"https://api.github.com/repos/buchgr/netty/contributors","subscribers_url":"https://api.github.com/repos/buchgr/netty/subscribers","subscription_url":"https://api.github.com/repos/buchgr/netty/subscription","commits_url":"https://api.github.com/repos/buchgr/netty/commits{/sha}","git_commits_url":"https://api.github.com/repos/buchgr/netty/git/commits{/sha}","comments_url":"https://api.github.com/repos/buchgr/netty/comments{/number}","issue_comment_url":"https://api.github.com/repos/buchgr/netty/issues/comments{/number}","contents_url":"https://api.github.com/repos/buchgr/netty/contents/{+path}","compare_url":"https://api.github.com/repos/buchgr/netty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/buchgr/netty/merges","archive_url":"https://api.github.com/repos/buchgr/netty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/buchgr/netty/downloads","issues_url":"https://api.github.com/repos/buchgr/netty/issues{/number}","pulls_url":"https://api.github.com/repos/buchgr/netty/pulls{/number}","milestones_url":"https://api.github.com/repos/buchgr/netty/milestones{/number}","notifications_url":"https://api.github.com/repos/buchgr/netty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/buchgr/netty/labels{/name}","releases_url":"https://api.github.com/repos/buchgr/netty/releases{/id}","created_at":"2014-02-27T02:09:39Z","updated_at":"2015-03-10T20:55:16Z","pushed_at":"2015-04-13T17:43:09Z","git_url":"git://github.com/buchgr/netty.git","ssh_url":"git@github.com:buchgr/netty.git","clone_url":"https://github.com/buchgr/netty.git","svn_url":"https://github.com/buchgr/netty","homepage":"http://netty.io/","size":39855,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"netty:master","ref":"master","sha":"9c4af6af7e59edf063c92b1d1eb7fddc432de586","user":{"login":"netty","id":473791,"avatar_url":"https://avatars.githubusercontent.com/u/473791?v=3","gravatar_id":"","url":"https://api.github.com/users/netty","html_url":"https://github.com/netty","followers_url":"https://api.github.com/users/netty/followers","following_url":"https://api.github.com/users/netty/following{/other_user}","gists_url":"https://api.github.com/users/netty/gists{/gist_id}","starred_url":"https://api.github.com/users/netty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netty/subscriptions","organizations_url":"https://api.github.com/users/netty/orgs","repos_url":"https://api.github.com/users/netty/repos","events_url":"https://api.github.com/users/netty/events{/privacy}","received_events_url":"https://api.github.com/users/netty/received_events","type":"Organization","site_admin":false},"repo":{"id":1064563,"name":"netty","full_name":"netty/netty","owner":{"login":"netty","id":473791,"avatar_url":"https://avatars.githubusercontent.com/u/473791?v=3","gravatar_id":"","url":"https://api.github.com/users/netty","html_url":"https://github.com/netty","followers_url":"https://api.github.com/users/netty/followers","following_url":"https://api.github.com/users/netty/following{/other_user}","gists_url":"https://api.github.com/users/netty/gists{/gist_id}","starred_url":"https://api.github.com/users/netty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netty/subscriptions","organizations_url":"https://api.github.com/users/netty/orgs","repos_url":"https://api.github.com/users/netty/repos","events_url":"https://api.github.com/users/netty/events{/privacy}","received_events_url":"https://api.github.com/users/netty/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/netty/netty","description":"Netty project - an event-driven asynchronous network application framework","fork":false,"url":"https://api.github.com/repos/netty/netty","forks_url":"https://api.github.com/repos/netty/netty/forks","keys_url":"https://api.github.com/repos/netty/netty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/netty/netty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/netty/netty/teams","hooks_url":"https://api.github.com/repos/netty/netty/hooks","issue_events_url":"https://api.github.com/repos/netty/netty/issues/events{/number}","events_url":"https://api.github.com/repos/netty/netty/events","assignees_url":"https://api.github.com/repos/netty/netty/assignees{/user}","branches_url":"https://api.github.com/repos/netty/netty/branches{/branch}","tags_url":"https://api.github.com/repos/netty/netty/tags","blobs_url":"https://api.github.com/repos/netty/netty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/netty/netty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/netty/netty/git/refs{/sha}","trees_url":"https://api.github.com/repos/netty/netty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/netty/netty/statuses/{sha}","languages_url":"https://api.github.com/repos/netty/netty/languages","stargazers_url":"https://api.github.com/repos/netty/netty/stargazers","contributors_url":"https://api.github.com/repos/netty/netty/contributors","subscribers_url":"https://api.github.com/repos/netty/netty/subscribers","subscription_url":"https://api.github.com/repos/netty/netty/subscription","commits_url":"https://api.github.com/repos/netty/netty/commits{/sha}","git_commits_url":"https://api.github.com/repos/netty/netty/git/commits{/sha}","comments_url":"https://api.github.com/repos/netty/netty/comments{/number}","issue_comment_url":"https://api.github.com/repos/netty/netty/issues/comments{/number}","contents_url":"https://api.github.com/repos/netty/netty/contents/{+path}","compare_url":"https://api.github.com/repos/netty/netty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/netty/netty/merges","archive_url":"https://api.github.com/repos/netty/netty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/netty/netty/downloads","issues_url":"https://api.github.com/repos/netty/netty/issues{/number}","pulls_url":"https://api.github.com/repos/netty/netty/pulls{/number}","milestones_url":"https://api.github.com/repos/netty/netty/milestones{/number}","notifications_url":"https://api.github.com/repos/netty/netty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/netty/netty/labels{/name}","releases_url":"https://api.github.com/repos/netty/netty/releases{/id}","created_at":"2010-11-09T09:22:21Z","updated_at":"2015-04-13T18:00:21Z","pushed_at":"2015-04-13T18:00:21Z","git_url":"git://github.com/netty/netty.git","ssh_url":"git@github.com:netty/netty.git","clone_url":"https://github.com/netty/netty.git","svn_url":"https://github.com/netty/netty","homepage":"http://netty.io/","size":115744,"stargazers_count":4409,"watchers_count":4409,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2168,"mirror_url":null,"open_issues_count":252,"forks":2168,"open_issues":252,"watchers":4409,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/netty/netty/pulls/3626"},"html":{"href":"https://github.com/netty/netty/pull/3626"},"issue":{"href":"https://api.github.com/repos/netty/netty/issues/3626"},"comments":{"href":"https://api.github.com/repos/netty/netty/issues/3626/comments"},"review_comments":{"href":"https://api.github.com/repos/netty/netty/pulls/3626/comments"},"review_comment":{"href":"https://api.github.com/repos/netty/netty/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/netty/netty/pulls/3626/commits"},"statuses":{"href":"https://api.github.com/repos/netty/netty/statuses/95af4d2e38951bd6f2259bdc693b3078c488515a"}}}}