{"action":"created","comment":{"url":"https://api.github.com/repos/pingcap/grpc-rs/pulls/comments/232487981","pull_request_review_id":173697818,"id":232487981,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMjQ4Nzk4MQ==","diff_hunk":"@@ -766,6 +838,64 @@ impl SinkBase {\n mod tests {\n     use super::*;\n \n+    #[test]\n+    fn byte_buffer_empty() {\n+        let mut buf = GrpcByteBuffer::default();\n+        unsafe {\n+            GrpcByteBuffer {\n+                raw: buf.take_raw(),\n+            }.len();","path":"src/call/mod.rs","position":271,"original_position":271,"commit_id":"1d1d4b2e774917b6514d6151aede5379008ca366","original_commit_id":"1d1d4b2e774917b6514d6151aede5379008ca366","user":{"login":"overvenus","id":2150711,"node_id":"MDQ6VXNlcjIxNTA3MTE=","avatar_url":"https://avatars0.githubusercontent.com/u/2150711?v=4","gravatar_id":"","url":"https://api.github.com/users/overvenus","html_url":"https://github.com/overvenus","followers_url":"https://api.github.com/users/overvenus/followers","following_url":"https://api.github.com/users/overvenus/following{/other_user}","gists_url":"https://api.github.com/users/overvenus/gists{/gist_id}","starred_url":"https://api.github.com/users/overvenus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/overvenus/subscriptions","organizations_url":"https://api.github.com/users/overvenus/orgs","repos_url":"https://api.github.com/users/overvenus/repos","events_url":"https://api.github.com/users/overvenus/events{/privacy}","received_events_url":"https://api.github.com/users/overvenus/received_events","type":"User","site_admin":false},"body":"Assert `is_empty`?","created_at":"2018-11-11T13:30:21Z","updated_at":"2018-11-11T13:32:38Z","html_url":"https://github.com/pingcap/grpc-rs/pull/238#discussion_r232487981","pull_request_url":"https://api.github.com/repos/pingcap/grpc-rs/pulls/238","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/pingcap/grpc-rs/pulls/comments/232487981"},"html":{"href":"https://github.com/pingcap/grpc-rs/pull/238#discussion_r232487981"},"pull_request":{"href":"https://api.github.com/repos/pingcap/grpc-rs/pulls/238"}}},"pull_request":{"url":"https://api.github.com/repos/pingcap/grpc-rs/pulls/238","id":221538440,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIxNTM4NDQw","html_url":"https://github.com/pingcap/grpc-rs/pull/238","diff_url":"https://github.com/pingcap/grpc-rs/pull/238.diff","patch_url":"https://github.com/pingcap/grpc-rs/pull/238.patch","issue_url":"https://api.github.com/repos/pingcap/grpc-rs/issues/238","number":238,"state":"open","locked":false,"title":"Reduce one copy for send","user":{"login":"ice1000","id":16398479,"node_id":"MDQ6VXNlcjE2Mzk4NDc5","avatar_url":"https://avatars3.githubusercontent.com/u/16398479?v=4","gravatar_id":"","url":"https://api.github.com/users/ice1000","html_url":"https://github.com/ice1000","followers_url":"https://api.github.com/users/ice1000/followers","following_url":"https://api.github.com/users/ice1000/following{/other_user}","gists_url":"https://api.github.com/users/ice1000/gists{/gist_id}","starred_url":"https://api.github.com/users/ice1000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ice1000/subscriptions","organizations_url":"https://api.github.com/users/ice1000/orgs","repos_url":"https://api.github.com/users/ice1000/repos","events_url":"https://api.github.com/users/ice1000/events{/privacy}","received_events_url":"https://api.github.com/users/ice1000/received_events","type":"User","site_admin":false},"body":"This is not ready to merge yet, but I'm opening this PR so we can discuss the changes.\r\n\r\n## TODOs\r\n\r\n+ [X] Fix benchmark compilation\r\n+ [x] Fix link error (multiple symbol definitions)\r\n+ [x] Fix `size_t` 6 in Rust becomes `size_t` in C 140184721559552 via FFI (140184721559552+6 is 2^47)\r\n+ [x] Sync master changes\r\n+ [x] Improve `GrpcSlice`\r\n+ [x] Improve `GrpcByteBuffer`\r\n\r\n## Before:\r\n\r\n+ User code deserialize (particularly, the protobuf library), producing a list of `&[u8]`, we copied the data into a `Vec<u8>`, this is done internally in the protobuf library (**copy 0**)\r\n+ We create a `grpc_slice` (a ref-counted single string) by copying the `Vec<u8>` mentioned above (**copy 1**)\r\n+ We create a `grpc_byte_buffer` (a ref-counted list of strings) from only one `grpc_slice`\r\n+ Send\r\n\r\n**Total copy: 2**\r\n\r\n## After:\r\n\r\n+ User code deserialize (particularly, the protobuf library), producing a list of `&[u8]`, we copied each produced `&[u8]` and collect them into a `Vec<GrpcSlice>` (**copy 0**)\r\n+ We create a `grpc_byte_buffer` from the collected `Vec<grpcSlice>`\r\n+ Send\r\n\r\n**Total copy: 1**\r\n\r\nThe reason why still one copy:\r\n\r\n+ Rust manages its own allocated memory'a lifetime\r\n+ C-side uses a ref-count mechanism to manage the lifetime of objects\r\n+ We either need to longer the Rust objects' lifetime or copy once\r\n+ Tried to longer Rust objects' lifetime in #225 \r\n  + Result: grpc supports buffer-hint which requires a much longer lifetime, it's too hard to manage the lifetime in such case\r\n  + This is why I closed #225 ","created_at":"2018-10-09T18:23:03Z","updated_at":"2018-11-11T13:32:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"87c15f459e5c9d32ee77e960ff10b77639dc3f2a","assignee":{"login":"ice1000","id":16398479,"node_id":"MDQ6VXNlcjE2Mzk4NDc5","avatar_url":"https://avatars3.githubusercontent.com/u/16398479?v=4","gravatar_id":"","url":"https://api.github.com/users/ice1000","html_url":"https://github.com/ice1000","followers_url":"https://api.github.com/users/ice1000/followers","following_url":"https://api.github.com/users/ice1000/following{/other_user}","gists_url":"https://api.github.com/users/ice1000/gists{/gist_id}","starred_url":"https://api.github.com/users/ice1000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ice1000/subscriptions","organizations_url":"https://api.github.com/users/ice1000/orgs","repos_url":"https://api.github.com/users/ice1000/repos","events_url":"https://api.github.com/users/ice1000/events{/privacy}","received_events_url":"https://api.github.com/users/ice1000/received_events","type":"User","site_admin":false},"assignees":[{"login":"ice1000","id":16398479,"node_id":"MDQ6VXNlcjE2Mzk4NDc5","avatar_url":"https://avatars3.githubusercontent.com/u/16398479?v=4","gravatar_id":"","url":"https://api.github.com/users/ice1000","html_url":"https://github.com/ice1000","followers_url":"https://api.github.com/users/ice1000/followers","following_url":"https://api.github.com/users/ice1000/following{/other_user}","gists_url":"https://api.github.com/users/ice1000/gists{/gist_id}","starred_url":"https://api.github.com/users/ice1000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ice1000/subscriptions","organizations_url":"https://api.github.com/users/ice1000/orgs","repos_url":"https://api.github.com/users/ice1000/repos","events_url":"https://api.github.com/users/ice1000/events{/privacy}","received_events_url":"https://api.github.com/users/ice1000/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":588702782,"node_id":"MDU6TGFiZWw1ODg3MDI3ODI=","url":"https://api.github.com/repos/pingcap/grpc-rs/labels/Enhancement","name":"Enhancement","color":"84b6eb","default":false},{"id":900083219,"node_id":"MDU6TGFiZWw5MDAwODMyMTk=","url":"https://api.github.com/repos/pingcap/grpc-rs/labels/Work%20In%20Progress","name":"Work In Progress","color":"f25287","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/pingcap/grpc-rs/pulls/238/commits","review_comments_url":"https://api.github.com/repos/pingcap/grpc-rs/pulls/238/comments","review_comment_url":"https://api.github.com/repos/pingcap/grpc-rs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pingcap/grpc-rs/issues/238/comments","statuses_url":"https://api.github.com/repos/pingcap/grpc-rs/statuses/1d1d4b2e774917b6514d6151aede5379008ca366","head":{"label":"ice1000:zero-copy-send-new","ref":"zero-copy-send-new","sha":"1d1d4b2e774917b6514d6151aede5379008ca366","user":{"login":"ice1000","id":16398479,"node_id":"MDQ6VXNlcjE2Mzk4NDc5","avatar_url":"https://avatars3.githubusercontent.com/u/16398479?v=4","gravatar_id":"","url":"https://api.github.com/users/ice1000","html_url":"https://github.com/ice1000","followers_url":"https://api.github.com/users/ice1000/followers","following_url":"https://api.github.com/users/ice1000/following{/other_user}","gists_url":"https://api.github.com/users/ice1000/gists{/gist_id}","starred_url":"https://api.github.com/users/ice1000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ice1000/subscriptions","organizations_url":"https://api.github.com/users/ice1000/orgs","repos_url":"https://api.github.com/users/ice1000/repos","events_url":"https://api.github.com/users/ice1000/events{/privacy}","received_events_url":"https://api.github.com/users/ice1000/received_events","type":"User","site_admin":false},"repo":{"id":145147357,"node_id":"MDEwOlJlcG9zaXRvcnkxNDUxNDczNTc=","name":"grpc-rs","full_name":"ice1000/grpc-rs","private":false,"owner":{"login":"ice1000","id":16398479,"node_id":"MDQ6VXNlcjE2Mzk4NDc5","avatar_url":"https://avatars3.githubusercontent.com/u/16398479?v=4","gravatar_id":"","url":"https://api.github.com/users/ice1000","html_url":"https://github.com/ice1000","followers_url":"https://api.github.com/users/ice1000/followers","following_url":"https://api.github.com/users/ice1000/following{/other_user}","gists_url":"https://api.github.com/users/ice1000/gists{/gist_id}","starred_url":"https://api.github.com/users/ice1000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ice1000/subscriptions","organizations_url":"https://api.github.com/users/ice1000/orgs","repos_url":"https://api.github.com/users/ice1000/repos","events_url":"https://api.github.com/users/ice1000/events{/privacy}","received_events_url":"https://api.github.com/users/ice1000/received_events","type":"User","site_admin":false},"html_url":"https://github.com/ice1000/grpc-rs","description":"The gRPC library for Rust built on C Core library and futures","fork":true,"url":"https://api.github.com/repos/ice1000/grpc-rs","forks_url":"https://api.github.com/repos/ice1000/grpc-rs/forks","keys_url":"https://api.github.com/repos/ice1000/grpc-rs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ice1000/grpc-rs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ice1000/grpc-rs/teams","hooks_url":"https://api.github.com/repos/ice1000/grpc-rs/hooks","issue_events_url":"https://api.github.com/repos/ice1000/grpc-rs/issues/events{/number}","events_url":"https://api.github.com/repos/ice1000/grpc-rs/events","assignees_url":"https://api.github.com/repos/ice1000/grpc-rs/assignees{/user}","branches_url":"https://api.github.com/repos/ice1000/grpc-rs/branches{/branch}","tags_url":"https://api.github.com/repos/ice1000/grpc-rs/tags","blobs_url":"https://api.github.com/repos/ice1000/grpc-rs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ice1000/grpc-rs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ice1000/grpc-rs/git/refs{/sha}","trees_url":"https://api.github.com/repos/ice1000/grpc-rs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ice1000/grpc-rs/statuses/{sha}","languages_url":"https://api.github.com/repos/ice1000/grpc-rs/languages","stargazers_url":"https://api.github.com/repos/ice1000/grpc-rs/stargazers","contributors_url":"https://api.github.com/repos/ice1000/grpc-rs/contributors","subscribers_url":"https://api.github.com/repos/ice1000/grpc-rs/subscribers","subscription_url":"https://api.github.com/repos/ice1000/grpc-rs/subscription","commits_url":"https://api.github.com/repos/ice1000/grpc-rs/commits{/sha}","git_commits_url":"https://api.github.com/repos/ice1000/grpc-rs/git/commits{/sha}","comments_url":"https://api.github.com/repos/ice1000/grpc-rs/comments{/number}","issue_comment_url":"https://api.github.com/repos/ice1000/grpc-rs/issues/comments{/number}","contents_url":"https://api.github.com/repos/ice1000/grpc-rs/contents/{+path}","compare_url":"https://api.github.com/repos/ice1000/grpc-rs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ice1000/grpc-rs/merges","archive_url":"https://api.github.com/repos/ice1000/grpc-rs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ice1000/grpc-rs/downloads","issues_url":"https://api.github.com/repos/ice1000/grpc-rs/issues{/number}","pulls_url":"https://api.github.com/repos/ice1000/grpc-rs/pulls{/number}","milestones_url":"https://api.github.com/repos/ice1000/grpc-rs/milestones{/number}","notifications_url":"https://api.github.com/repos/ice1000/grpc-rs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ice1000/grpc-rs/labels{/name}","releases_url":"https://api.github.com/repos/ice1000/grpc-rs/releases{/id}","deployments_url":"https://api.github.com/repos/ice1000/grpc-rs/deployments","created_at":"2018-08-17T17:14:15Z","updated_at":"2018-10-19T06:13:06Z","pushed_at":"2018-11-10T19:18:38Z","git_url":"git://github.com/ice1000/grpc-rs.git","ssh_url":"git@github.com:ice1000/grpc-rs.git","clone_url":"https://github.com/ice1000/grpc-rs.git","svn_url":"https://github.com/ice1000/grpc-rs","homepage":"","size":877,"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":"pingcap:master","ref":"master","sha":"f1c6bc6210332ae922042b3286d247e7fe71ce52","user":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"repo":{"id":88956492,"node_id":"MDEwOlJlcG9zaXRvcnk4ODk1NjQ5Mg==","name":"grpc-rs","full_name":"pingcap/grpc-rs","private":false,"owner":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/pingcap/grpc-rs","description":"The gRPC library for Rust built on C Core library and futures","fork":false,"url":"https://api.github.com/repos/pingcap/grpc-rs","forks_url":"https://api.github.com/repos/pingcap/grpc-rs/forks","keys_url":"https://api.github.com/repos/pingcap/grpc-rs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/grpc-rs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/grpc-rs/teams","hooks_url":"https://api.github.com/repos/pingcap/grpc-rs/hooks","issue_events_url":"https://api.github.com/repos/pingcap/grpc-rs/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/grpc-rs/events","assignees_url":"https://api.github.com/repos/pingcap/grpc-rs/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/grpc-rs/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/grpc-rs/tags","blobs_url":"https://api.github.com/repos/pingcap/grpc-rs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/grpc-rs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/grpc-rs/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/grpc-rs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/grpc-rs/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/grpc-rs/languages","stargazers_url":"https://api.github.com/repos/pingcap/grpc-rs/stargazers","contributors_url":"https://api.github.com/repos/pingcap/grpc-rs/contributors","subscribers_url":"https://api.github.com/repos/pingcap/grpc-rs/subscribers","subscription_url":"https://api.github.com/repos/pingcap/grpc-rs/subscription","commits_url":"https://api.github.com/repos/pingcap/grpc-rs/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/grpc-rs/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/grpc-rs/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/grpc-rs/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/grpc-rs/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/grpc-rs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/grpc-rs/merges","archive_url":"https://api.github.com/repos/pingcap/grpc-rs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/grpc-rs/downloads","issues_url":"https://api.github.com/repos/pingcap/grpc-rs/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/grpc-rs/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/grpc-rs/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/grpc-rs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/grpc-rs/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/grpc-rs/releases{/id}","deployments_url":"https://api.github.com/repos/pingcap/grpc-rs/deployments","created_at":"2017-04-21T07:41:57Z","updated_at":"2018-11-09T16:55:49Z","pushed_at":"2018-11-10T19:18:40Z","git_url":"git://github.com/pingcap/grpc-rs.git","ssh_url":"git@github.com:pingcap/grpc-rs.git","clone_url":"https://github.com/pingcap/grpc-rs.git","svn_url":"https://github.com/pingcap/grpc-rs","homepage":"","size":664,"stargazers_count":455,"watchers_count":455,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":71,"mirror_url":null,"archived":false,"open_issues_count":35,"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":71,"open_issues":35,"watchers":455,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pingcap/grpc-rs/pulls/238"},"html":{"href":"https://github.com/pingcap/grpc-rs/pull/238"},"issue":{"href":"https://api.github.com/repos/pingcap/grpc-rs/issues/238"},"comments":{"href":"https://api.github.com/repos/pingcap/grpc-rs/issues/238/comments"},"review_comments":{"href":"https://api.github.com/repos/pingcap/grpc-rs/pulls/238/comments"},"review_comment":{"href":"https://api.github.com/repos/pingcap/grpc-rs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pingcap/grpc-rs/pulls/238/commits"},"statuses":{"href":"https://api.github.com/repos/pingcap/grpc-rs/statuses/1d1d4b2e774917b6514d6151aede5379008ca366"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"overvenus"}}