{"action":"created","issue":{"url":"https://api.github.com/repos/ceph/ceph/issues/9795","repository_url":"https://api.github.com/repos/ceph/ceph","labels_url":"https://api.github.com/repos/ceph/ceph/issues/9795/labels{/name}","comments_url":"https://api.github.com/repos/ceph/ceph/issues/9795/comments","events_url":"https://api.github.com/repos/ceph/ceph/issues/9795/events","html_url":"https://github.com/ceph/ceph/pull/9795","id":161010337,"number":9795,"title":"common: Improve linux dcache hash algorithm","user":{"login":"cyb70289","id":4149843,"avatar_url":"https://avatars.githubusercontent.com/u/4149843?v=3","gravatar_id":"","url":"https://api.github.com/users/cyb70289","html_url":"https://github.com/cyb70289","followers_url":"https://api.github.com/users/cyb70289/followers","following_url":"https://api.github.com/users/cyb70289/following{/other_user}","gists_url":"https://api.github.com/users/cyb70289/gists{/gist_id}","starred_url":"https://api.github.com/users/cyb70289/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyb70289/subscriptions","organizations_url":"https://api.github.com/users/cyb70289/orgs","repos_url":"https://api.github.com/users/cyb70289/repos","events_url":"https://api.github.com/users/cyb70289/events{/privacy}","received_events_url":"https://api.github.com/users/cyb70289/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ceph/ceph/labels/common","name":"common","color":"006b75"},{"url":"https://api.github.com/repos/ceph/ceph/labels/needs-qa","name":"needs-qa","color":"fad8c7"},{"url":"https://api.github.com/repos/ceph/ceph/labels/performance","name":"performance","color":"bfdadc"},{"url":"https://api.github.com/repos/ceph/ceph/labels/wip-yuri-testing2","name":"wip-yuri-testing2","color":"e99695"}],"state":"closed","locked":false,"assignee":{"login":"tchaikov","id":59071,"avatar_url":"https://avatars.githubusercontent.com/u/59071?v=3","gravatar_id":"","url":"https://api.github.com/users/tchaikov","html_url":"https://github.com/tchaikov","followers_url":"https://api.github.com/users/tchaikov/followers","following_url":"https://api.github.com/users/tchaikov/following{/other_user}","gists_url":"https://api.github.com/users/tchaikov/gists{/gist_id}","starred_url":"https://api.github.com/users/tchaikov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tchaikov/subscriptions","organizations_url":"https://api.github.com/users/tchaikov/orgs","repos_url":"https://api.github.com/users/tchaikov/repos","events_url":"https://api.github.com/users/tchaikov/events{/privacy}","received_events_url":"https://api.github.com/users/tchaikov/received_events","type":"User","site_admin":false},"assignees":[{"login":"tchaikov","id":59071,"avatar_url":"https://avatars.githubusercontent.com/u/59071?v=3","gravatar_id":"","url":"https://api.github.com/users/tchaikov","html_url":"https://github.com/tchaikov","followers_url":"https://api.github.com/users/tchaikov/followers","following_url":"https://api.github.com/users/tchaikov/following{/other_user}","gists_url":"https://api.github.com/users/tchaikov/gists{/gist_id}","starred_url":"https://api.github.com/users/tchaikov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tchaikov/subscriptions","organizations_url":"https://api.github.com/users/tchaikov/orgs","repos_url":"https://api.github.com/users/tchaikov/repos","events_url":"https://api.github.com/users/tchaikov/events{/privacy}","received_events_url":"https://api.github.com/users/tchaikov/received_events","type":"User","site_admin":false}],"milestone":null,"comments":7,"created_at":"2016-06-18T06:41:19Z","updated_at":"2016-10-18T11:14:59Z","closed_at":"2016-06-27T22:02:05Z","pull_request":{"url":"https://api.github.com/repos/ceph/ceph/pulls/9795","html_url":"https://github.com/ceph/ceph/pull/9795","diff_url":"https://github.com/ceph/ceph/pull/9795.diff","patch_url":"https://github.com/ceph/ceph/pull/9795.patch"},"body":"http://tracker.ceph.com/issues/17599\r\n\r\nTest code for profiling: [hash-profile2.tar.gz](https://github.com/ceph/ceph/files/325058/hash-profile2.tar.gz)\r\n\r\nIn ceph_str_hash_linux(), hash value is defined as unsigned **long**,\r\nwhich is 8 bytes on 64-bit platforms when compiled with gcc. But\r\nthe return value is truncated to 4 bytes, and there's no need to\r\npreserve 8 bytes intermediate value in the algorithm. The compiler\r\ndoesn't figure out this fact and produces redundant code.\r\n\r\n```c\r\nunsigned ceph_str_hash_linux(const char *str, unsigned length)\r\n{\r\n        /* \"long\" introduces performance penalty, should be deleted. */\r\n        unsigned long hash = 0;\r\n\r\n        while (length--) {\r\n                unsigned char c = *str++; \r\n                hash = (hash + (c << 4) + (c >> 4)) * 11;\r\n        }\r\n        return hash;\r\n}\r\n```\r\n\r\nAfter removing the \"long\" definition, this route runs much faster.\r\nFollowing result are tested on x86_64 and aarch64 platforms, built\r\nby gcc 5.3.1 with optimization level -O2. Same output is observed\r\nwith gcc 4.8.4 and -O3 optimization.\r\n\r\n*ARM Cortex-A57*\r\n\r\nString Length | Time w/ long | Time w/o long | Improvement \r\n------------- | ------------ | ------------- | -----------\r\n 32            | 0.088 us     | 0.067 us      | 24%         \r\n 4096          | 10.26 us     | 8.20 us       | 20%         \r\n 65536         | 164 us       | 131 us        | 20%         \r\n 1048576       | 2624 us      | 2099 us       | 20%         \r\n\r\n*Intel i7-4790*\r\n\r\nString Length | Time w/ long | Time w/o long | Improvement\r\n--------------- | -------------- | --------------- | -------------\r\n 32            | 0.033 us     | 0.028 us      | 16.3%       \r\n 4096          | 3.87 us      | 3.64 us       | 6.2%        \r\n 65536         | 61.3 us      | 57.8 us       | 5.7%        \r\n 1048576       | 973 us       | 917 us        | 5.8%        \r\n\r\nSigned-off-by: Yibo Cai <yibo.cai@linaro.org>"},"comment":{"url":"https://api.github.com/repos/ceph/ceph/issues/comments/254477753","html_url":"https://github.com/ceph/ceph/pull/9795#issuecomment-254477753","issue_url":"https://api.github.com/repos/ceph/ceph/issues/9795","id":254477753,"user":{"login":"smithfarm","id":3974844,"avatar_url":"https://avatars.githubusercontent.com/u/3974844?v=3","gravatar_id":"","url":"https://api.github.com/users/smithfarm","html_url":"https://github.com/smithfarm","followers_url":"https://api.github.com/users/smithfarm/followers","following_url":"https://api.github.com/users/smithfarm/following{/other_user}","gists_url":"https://api.github.com/users/smithfarm/gists{/gist_id}","starred_url":"https://api.github.com/users/smithfarm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smithfarm/subscriptions","organizations_url":"https://api.github.com/users/smithfarm/orgs","repos_url":"https://api.github.com/users/smithfarm/repos","events_url":"https://api.github.com/users/smithfarm/events{/privacy}","received_events_url":"https://api.github.com/users/smithfarm/received_events","type":"User","site_admin":false},"created_at":"2016-10-18T11:14:59Z","updated_at":"2016-10-18T11:14:59Z","body":"Opened tracker issue http://tracker.ceph.com/issues/17599"}}
{"actor":{"display_login":"smithfarm"}}