{"action":"created","comment":{"url":"https://api.github.com/repos/tikv/tikv/pulls/comments/209331263","pull_request_review_id":145331126,"id":209331263,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwOTMzMTI2Mw==","diff_hunk":"@@ -162,34 +163,44 @@ pub fn decode_compact_bytes(data: &mut BytesSlice) -> Result<Vec<u8>> {\n     Err(Error::unexpected_eof())\n }\n \n+\n+/// `decode_bytes` decodes bytes which is encoded by `encoded_bytes` before.","path":"src/util/codec/bytes.rs","position":13,"original_position":13,"commit_id":"521481aaadc984539403d7280acb3709f2e28ed1","original_commit_id":"521481aaadc984539403d7280acb3709f2e28ed1","user":{"login":"breeswish","id":1916485,"node_id":"MDQ6VXNlcjE5MTY0ODU=","avatar_url":"https://avatars3.githubusercontent.com/u/1916485?v=4","gravatar_id":"","url":"https://api.github.com/users/breeswish","html_url":"https://github.com/breeswish","followers_url":"https://api.github.com/users/breeswish/followers","following_url":"https://api.github.com/users/breeswish/following{/other_user}","gists_url":"https://api.github.com/users/breeswish/gists{/gist_id}","starred_url":"https://api.github.com/users/breeswish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/breeswish/subscriptions","organizations_url":"https://api.github.com/users/breeswish/orgs","repos_url":"https://api.github.com/users/breeswish/repos","events_url":"https://api.github.com/users/breeswish/events{/privacy}","received_events_url":"https://api.github.com/users/breeswish/received_events","type":"User","site_admin":false},"body":"typo: `encode_bytes`.","created_at":"2018-08-10T17:27:32Z","updated_at":"2018-08-10T17:27:32Z","html_url":"https://github.com/tikv/tikv/pull/3427#discussion_r209331263","pull_request_url":"https://api.github.com/repos/tikv/tikv/pulls/3427","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/tikv/tikv/pulls/comments/209331263"},"html":{"href":"https://github.com/tikv/tikv/pull/3427#discussion_r209331263"},"pull_request":{"href":"https://api.github.com/repos/tikv/tikv/pulls/3427"}}},"pull_request":{"url":"https://api.github.com/repos/tikv/tikv/pulls/3427","id":207531474,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA3NTMxNDc0","html_url":"https://github.com/tikv/tikv/pull/3427","diff_url":"https://github.com/tikv/tikv/pull/3427.diff","patch_url":"https://github.com/tikv/tikv/pull/3427.patch","issue_url":"https://api.github.com/repos/tikv/tikv/issues/3427","number":3427,"state":"open","locked":false,"title":"util: decode bytes inplace","user":{"login":"Connor1996","id":13497871,"node_id":"MDQ6VXNlcjEzNDk3ODcx","avatar_url":"https://avatars1.githubusercontent.com/u/13497871?v=4","gravatar_id":"","url":"https://api.github.com/users/Connor1996","html_url":"https://github.com/Connor1996","followers_url":"https://api.github.com/users/Connor1996/followers","following_url":"https://api.github.com/users/Connor1996/following{/other_user}","gists_url":"https://api.github.com/users/Connor1996/gists{/gist_id}","starred_url":"https://api.github.com/users/Connor1996/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Connor1996/subscriptions","organizations_url":"https://api.github.com/users/Connor1996/orgs","repos_url":"https://api.github.com/users/Connor1996/repos","events_url":"https://api.github.com/users/Connor1996/events{/privacy}","received_events_url":"https://api.github.com/users/Connor1996/received_events","type":"User","site_admin":false},"body":"## What have you changed? (mandatory)\r\n- add `decode_bytes_inplace()` to save mallocation\r\n- add `take_raw()` for `Key` which use `decode_bytes_inplace()`\r\n- call `take_raw()` instead of `raw()` in some code place\r\n\r\n## What are the type of the changes? (mandatory)\r\n- Improvement (non-breaking change which is an improvement to an existing feature)\r\n\r\n## How has this PR been tested? (mandatory)\r\nunit-test\r\n\r\n## Does this PR affect documentation (docs/docs-cn) update? (mandatory)\r\nNo\r\n\r\n## Does this PR affect tidb-ansible update? (mandatory)\r\nNo\r\n\r\n## Benchmark result if necessary (optional)\r\nI write a micro bench for two decode_bytes_inplace implementation.\r\none for copying bytes one by one\r\n```rust\r\n for i in write_offset..(write_offset + ENC_GROUP_SIZE){\r\n     data[i] = data[read_offset];\r\n     read_offset += 1;\r\n}\r\n```\r\nthe other for memmoving 8 bytes in one shot\r\n```rust\r\nptr::copy(\r\n    data.as_ptr().offset(read_offset as isize),\r\n    data.as_mut_ptr().offset(write_offset as isize),\r\n    ENC_GROUP_SIZE - pad_size\r\n);\r\n```\r\nhere is the result\r\n```\r\ntest util::codec::bytes::tests::bench_decode                 ... bench:   3,291,861 ns/iter (+/- 234,919)\r\ntest util::codec::bytes::tests::bench_decode_inplace_copy    ... bench:   4,772,352 ns/iter (+/- 1,063,849)\r\ntest util::codec::bytes::tests::bench_decode_inplace_memmove ... bench:   2,591,718 ns/iter (+/- 557,794)\r\n```\r\n\r\n","created_at":"2018-08-10T07:43:28Z","updated_at":"2018-08-10T17:27:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ffa8f56710d8e76b30e63d4304d1aa559561d446","assignee":null,"assignees":[],"requested_reviewers":[{"login":"MyonKeminta","id":9948422,"node_id":"MDQ6VXNlcjk5NDg0MjI=","avatar_url":"https://avatars1.githubusercontent.com/u/9948422?v=4","gravatar_id":"","url":"https://api.github.com/users/MyonKeminta","html_url":"https://github.com/MyonKeminta","followers_url":"https://api.github.com/users/MyonKeminta/followers","following_url":"https://api.github.com/users/MyonKeminta/following{/other_user}","gists_url":"https://api.github.com/users/MyonKeminta/gists{/gist_id}","starred_url":"https://api.github.com/users/MyonKeminta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MyonKeminta/subscriptions","organizations_url":"https://api.github.com/users/MyonKeminta/orgs","repos_url":"https://api.github.com/users/MyonKeminta/repos","events_url":"https://api.github.com/users/MyonKeminta/events{/privacy}","received_events_url":"https://api.github.com/users/MyonKeminta/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/tikv/tikv/pulls/3427/commits","review_comments_url":"https://api.github.com/repos/tikv/tikv/pulls/3427/comments","review_comment_url":"https://api.github.com/repos/tikv/tikv/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tikv/tikv/issues/3427/comments","statuses_url":"https://api.github.com/repos/tikv/tikv/statuses/521481aaadc984539403d7280acb3709f2e28ed1","head":{"label":"Connor1996:encode-inplace","ref":"encode-inplace","sha":"521481aaadc984539403d7280acb3709f2e28ed1","user":{"login":"Connor1996","id":13497871,"node_id":"MDQ6VXNlcjEzNDk3ODcx","avatar_url":"https://avatars1.githubusercontent.com/u/13497871?v=4","gravatar_id":"","url":"https://api.github.com/users/Connor1996","html_url":"https://github.com/Connor1996","followers_url":"https://api.github.com/users/Connor1996/followers","following_url":"https://api.github.com/users/Connor1996/following{/other_user}","gists_url":"https://api.github.com/users/Connor1996/gists{/gist_id}","starred_url":"https://api.github.com/users/Connor1996/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Connor1996/subscriptions","organizations_url":"https://api.github.com/users/Connor1996/orgs","repos_url":"https://api.github.com/users/Connor1996/repos","events_url":"https://api.github.com/users/Connor1996/events{/privacy}","received_events_url":"https://api.github.com/users/Connor1996/received_events","type":"User","site_admin":false},"repo":{"id":95129535,"node_id":"MDEwOlJlcG9zaXRvcnk5NTEyOTUzNQ==","name":"tikv","full_name":"Connor1996/tikv","owner":{"login":"Connor1996","id":13497871,"node_id":"MDQ6VXNlcjEzNDk3ODcx","avatar_url":"https://avatars1.githubusercontent.com/u/13497871?v=4","gravatar_id":"","url":"https://api.github.com/users/Connor1996","html_url":"https://github.com/Connor1996","followers_url":"https://api.github.com/users/Connor1996/followers","following_url":"https://api.github.com/users/Connor1996/following{/other_user}","gists_url":"https://api.github.com/users/Connor1996/gists{/gist_id}","starred_url":"https://api.github.com/users/Connor1996/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Connor1996/subscriptions","organizations_url":"https://api.github.com/users/Connor1996/orgs","repos_url":"https://api.github.com/users/Connor1996/repos","events_url":"https://api.github.com/users/Connor1996/events{/privacy}","received_events_url":"https://api.github.com/users/Connor1996/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Connor1996/tikv","description":"Distributed transactional key value database powered by Rust and Raft","fork":true,"url":"https://api.github.com/repos/Connor1996/tikv","forks_url":"https://api.github.com/repos/Connor1996/tikv/forks","keys_url":"https://api.github.com/repos/Connor1996/tikv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Connor1996/tikv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Connor1996/tikv/teams","hooks_url":"https://api.github.com/repos/Connor1996/tikv/hooks","issue_events_url":"https://api.github.com/repos/Connor1996/tikv/issues/events{/number}","events_url":"https://api.github.com/repos/Connor1996/tikv/events","assignees_url":"https://api.github.com/repos/Connor1996/tikv/assignees{/user}","branches_url":"https://api.github.com/repos/Connor1996/tikv/branches{/branch}","tags_url":"https://api.github.com/repos/Connor1996/tikv/tags","blobs_url":"https://api.github.com/repos/Connor1996/tikv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Connor1996/tikv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Connor1996/tikv/git/refs{/sha}","trees_url":"https://api.github.com/repos/Connor1996/tikv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Connor1996/tikv/statuses/{sha}","languages_url":"https://api.github.com/repos/Connor1996/tikv/languages","stargazers_url":"https://api.github.com/repos/Connor1996/tikv/stargazers","contributors_url":"https://api.github.com/repos/Connor1996/tikv/contributors","subscribers_url":"https://api.github.com/repos/Connor1996/tikv/subscribers","subscription_url":"https://api.github.com/repos/Connor1996/tikv/subscription","commits_url":"https://api.github.com/repos/Connor1996/tikv/commits{/sha}","git_commits_url":"https://api.github.com/repos/Connor1996/tikv/git/commits{/sha}","comments_url":"https://api.github.com/repos/Connor1996/tikv/comments{/number}","issue_comment_url":"https://api.github.com/repos/Connor1996/tikv/issues/comments{/number}","contents_url":"https://api.github.com/repos/Connor1996/tikv/contents/{+path}","compare_url":"https://api.github.com/repos/Connor1996/tikv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Connor1996/tikv/merges","archive_url":"https://api.github.com/repos/Connor1996/tikv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Connor1996/tikv/downloads","issues_url":"https://api.github.com/repos/Connor1996/tikv/issues{/number}","pulls_url":"https://api.github.com/repos/Connor1996/tikv/pulls{/number}","milestones_url":"https://api.github.com/repos/Connor1996/tikv/milestones{/number}","notifications_url":"https://api.github.com/repos/Connor1996/tikv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Connor1996/tikv/labels{/name}","releases_url":"https://api.github.com/repos/Connor1996/tikv/releases{/id}","deployments_url":"https://api.github.com/repos/Connor1996/tikv/deployments","created_at":"2017-06-22T15:24:52Z","updated_at":"2018-08-07T00:45:11Z","pushed_at":"2018-08-10T17:13:36Z","git_url":"git://github.com/Connor1996/tikv.git","ssh_url":"git@github.com:Connor1996/tikv.git","clone_url":"https://github.com/Connor1996/tikv.git","svn_url":"https://github.com/Connor1996/tikv","homepage":"https://pingcap.com","size":15714,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"tikv:master","ref":"master","sha":"e516dbda254add22df095e6f1e5481db4c7f58c9","user":{"login":"tikv","id":41004122,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDA0MTIy","avatar_url":"https://avatars2.githubusercontent.com/u/41004122?v=4","gravatar_id":"","url":"https://api.github.com/users/tikv","html_url":"https://github.com/tikv","followers_url":"https://api.github.com/users/tikv/followers","following_url":"https://api.github.com/users/tikv/following{/other_user}","gists_url":"https://api.github.com/users/tikv/gists{/gist_id}","starred_url":"https://api.github.com/users/tikv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tikv/subscriptions","organizations_url":"https://api.github.com/users/tikv/orgs","repos_url":"https://api.github.com/users/tikv/repos","events_url":"https://api.github.com/users/tikv/events{/privacy}","received_events_url":"https://api.github.com/users/tikv/received_events","type":"Organization","site_admin":false},"repo":{"id":48833910,"node_id":"MDEwOlJlcG9zaXRvcnk0ODgzMzkxMA==","name":"tikv","full_name":"tikv/tikv","owner":{"login":"tikv","id":41004122,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDA0MTIy","avatar_url":"https://avatars2.githubusercontent.com/u/41004122?v=4","gravatar_id":"","url":"https://api.github.com/users/tikv","html_url":"https://github.com/tikv","followers_url":"https://api.github.com/users/tikv/followers","following_url":"https://api.github.com/users/tikv/following{/other_user}","gists_url":"https://api.github.com/users/tikv/gists{/gist_id}","starred_url":"https://api.github.com/users/tikv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tikv/subscriptions","organizations_url":"https://api.github.com/users/tikv/orgs","repos_url":"https://api.github.com/users/tikv/repos","events_url":"https://api.github.com/users/tikv/events{/privacy}","received_events_url":"https://api.github.com/users/tikv/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tikv/tikv","description":"Distributed transactional key value database powered by Rust and Raft","fork":false,"url":"https://api.github.com/repos/tikv/tikv","forks_url":"https://api.github.com/repos/tikv/tikv/forks","keys_url":"https://api.github.com/repos/tikv/tikv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tikv/tikv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tikv/tikv/teams","hooks_url":"https://api.github.com/repos/tikv/tikv/hooks","issue_events_url":"https://api.github.com/repos/tikv/tikv/issues/events{/number}","events_url":"https://api.github.com/repos/tikv/tikv/events","assignees_url":"https://api.github.com/repos/tikv/tikv/assignees{/user}","branches_url":"https://api.github.com/repos/tikv/tikv/branches{/branch}","tags_url":"https://api.github.com/repos/tikv/tikv/tags","blobs_url":"https://api.github.com/repos/tikv/tikv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tikv/tikv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tikv/tikv/git/refs{/sha}","trees_url":"https://api.github.com/repos/tikv/tikv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tikv/tikv/statuses/{sha}","languages_url":"https://api.github.com/repos/tikv/tikv/languages","stargazers_url":"https://api.github.com/repos/tikv/tikv/stargazers","contributors_url":"https://api.github.com/repos/tikv/tikv/contributors","subscribers_url":"https://api.github.com/repos/tikv/tikv/subscribers","subscription_url":"https://api.github.com/repos/tikv/tikv/subscription","commits_url":"https://api.github.com/repos/tikv/tikv/commits{/sha}","git_commits_url":"https://api.github.com/repos/tikv/tikv/git/commits{/sha}","comments_url":"https://api.github.com/repos/tikv/tikv/comments{/number}","issue_comment_url":"https://api.github.com/repos/tikv/tikv/issues/comments{/number}","contents_url":"https://api.github.com/repos/tikv/tikv/contents/{+path}","compare_url":"https://api.github.com/repos/tikv/tikv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tikv/tikv/merges","archive_url":"https://api.github.com/repos/tikv/tikv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tikv/tikv/downloads","issues_url":"https://api.github.com/repos/tikv/tikv/issues{/number}","pulls_url":"https://api.github.com/repos/tikv/tikv/pulls{/number}","milestones_url":"https://api.github.com/repos/tikv/tikv/milestones{/number}","notifications_url":"https://api.github.com/repos/tikv/tikv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tikv/tikv/labels{/name}","releases_url":"https://api.github.com/repos/tikv/tikv/releases{/id}","deployments_url":"https://api.github.com/repos/tikv/tikv/deployments","created_at":"2015-12-31T04:51:32Z","updated_at":"2018-08-10T15:14:14Z","pushed_at":"2018-08-10T17:25:00Z","git_url":"git://github.com/tikv/tikv.git","ssh_url":"git@github.com:tikv/tikv.git","clone_url":"https://github.com/tikv/tikv.git","svn_url":"https://github.com/tikv/tikv","homepage":"https://pingcap.com","size":15076,"stargazers_count":3470,"watchers_count":3470,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":463,"mirror_url":null,"archived":false,"open_issues_count":244,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":463,"open_issues":244,"watchers":3470,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tikv/tikv/pulls/3427"},"html":{"href":"https://github.com/tikv/tikv/pull/3427"},"issue":{"href":"https://api.github.com/repos/tikv/tikv/issues/3427"},"comments":{"href":"https://api.github.com/repos/tikv/tikv/issues/3427/comments"},"review_comments":{"href":"https://api.github.com/repos/tikv/tikv/pulls/3427/comments"},"review_comment":{"href":"https://api.github.com/repos/tikv/tikv/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tikv/tikv/pulls/3427/commits"},"statuses":{"href":"https://api.github.com/repos/tikv/tikv/statuses/521481aaadc984539403d7280acb3709f2e28ed1"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"breeswish"}}