{"action":"created","comment":{"url":"https://api.github.com/repos/openucx/ucx/pulls/comments/156866283","pull_request_review_id":83411088,"id":156866283,"diff_hunk":"@@ -303,117 +282,103 @@ UCS_PROFILE_FUNC(ucs_status_ptr_t, ucp_stream_recv_nb,\n     goto out;\n }\n \n-static UCS_F_ALWAYS_INLINE ucp_recv_desc_t *\n-ucp_stream_am_rdesc_get(ucp_worker_t *worker, ucp_stream_am_data_t *am_data,\n-                        size_t length, unsigned am_flags)\n+static UCS_F_ALWAYS_INLINE ucs_status_t\n+ucp_stream_am_data_process(ucp_worker_t *worker, ucp_ep_ext_stream_t *ep,\n+                           ucp_stream_am_data_t *am_data, size_t length,\n+                           unsigned am_flags)\n {\n+    ucp_recv_desc_t  rdesc_tmp;\n+    void            *payload;\n     ucp_recv_desc_t *rdesc;\n+    ucp_request_t   *req;\n+    ssize_t          unpacked;\n+\n+    rdesc_tmp.length         = length;\n+    rdesc_tmp.payload_offset = sizeof(*am_data); /* add sizeof(*rdesc) only if\n+                                                    am_data wont be handled in\n+                                                    place */\n+\n+    /* First, process expected requests */\n+    if (ep->am_data_len == 0) {\n+        while (!ucs_queue_is_empty(&ep->reqs)) {\n+            req      = ucs_queue_head_elem_non_empty(&ep->reqs, ucp_request_t,\n+                                                     recv.queue);\n+            payload  = UCS_PTR_BYTE_OFFSET(am_data, rdesc_tmp.payload_offset);\n+            unpacked = ucp_stream_rdata_unpack(payload, rdesc_tmp.length, req);\n+            if (ucs_unlikely(unpacked < 0)) {\n+                ucs_fatal(\"failed to unpack from am_data %p with offset %u to request %p\",\n+                          am_data, rdesc_tmp.payload_offset, req);\n+            } else if (unpacked == rdesc_tmp.length) {\n+                ucp_request_complete_stream_recv(req, ep, UCS_OK);\n+                return UCS_OK;\n+            }\n+            ucp_stream_rdesc_advance(&rdesc_tmp, unpacked);\n+            /* This request is full, try next one */\n+            ucp_request_complete_stream_recv(req, ep, UCS_OK);\n+        }\n+    }\n \n-    if (ucs_unlikely(am_flags & UCT_CB_PARAM_FLAG_DESC)) {\n+    ucs_assert(rdesc_tmp.length > 0);\n+\n+    /* Now, enqueue the rest of data */\n+    if (ucs_likely(!(am_flags & UCT_CB_PARAM_FLAG_DESC))) {\n+        rdesc = (ucp_recv_desc_t*)ucs_mpool_get_inline(&worker->am_mp);\n+        ucs_assertv_always(rdesc != NULL,\n+                           \"ucp recv descriptor is not allocated\");\n+        rdesc->length         = rdesc_tmp.length;\n+        /* reset offset to improve locality */\n+        rdesc->payload_offset = sizeof(*rdesc) + sizeof(*am_data);\n+        rdesc->flags          = 0;\n+        memcpy(ucp_stream_rdesc_payload(rdesc),\n+               UCS_PTR_BYTE_OFFSET(am_data, rdesc_tmp.payload_offset),\n+               rdesc_tmp.length);\n+    } else {\n         /* slowpath */\n         rdesc        = (ucp_recv_desc_t *)am_data - 1;\n-        rdesc->flags = UCP_RECV_DESC_FLAG_UCT_DESC;\n-    } else {\n-        /* TODO: optimize if there are posted recvs */\n-        rdesc = (ucp_recv_desc_t*)ucs_mpool_get_inline(&worker->am_mp);\n-        if (ucs_likely(rdesc != NULL)) {\n-            rdesc->flags = 0;\n-            memcpy((ucp_stream_am_data_t *)(rdesc + 1) + 1, am_data + 1, length);\n-        } else {\n-            ucs_fatal(\"ucp recv descriptor is not allocated\");\n-        }\n+        rdesc->length         = rdesc_tmp.length;","path":"src/ucp/stream/stream_recv.c","position":288,"original_position":288,"commit_id":"dc2fd3170a4991269778d230b075ba509245f250","original_commit_id":"dc2fd3170a4991269778d230b075ba509245f250","user":{"login":"evgeny-leksikov","id":15216359,"avatar_url":"https://avatars3.githubusercontent.com/u/15216359?v=4","gravatar_id":"","url":"https://api.github.com/users/evgeny-leksikov","html_url":"https://github.com/evgeny-leksikov","followers_url":"https://api.github.com/users/evgeny-leksikov/followers","following_url":"https://api.github.com/users/evgeny-leksikov/following{/other_user}","gists_url":"https://api.github.com/users/evgeny-leksikov/gists{/gist_id}","starred_url":"https://api.github.com/users/evgeny-leksikov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evgeny-leksikov/subscriptions","organizations_url":"https://api.github.com/users/evgeny-leksikov/orgs","repos_url":"https://api.github.com/users/evgeny-leksikov/repos","events_url":"https://api.github.com/users/evgeny-leksikov/events{/privacy}","received_events_url":"https://api.github.com/users/evgeny-leksikov/received_events","type":"User","site_admin":false},"body":"`rdesc->flags = am_flags` will not work  - they have different types","created_at":"2017-12-14T06:56:09Z","updated_at":"2017-12-14T06:56:09Z","html_url":"https://github.com/openucx/ucx/pull/2060#discussion_r156866283","pull_request_url":"https://api.github.com/repos/openucx/ucx/pulls/2060","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/openucx/ucx/pulls/comments/156866283"},"html":{"href":"https://github.com/openucx/ucx/pull/2060#discussion_r156866283"},"pull_request":{"href":"https://api.github.com/repos/openucx/ucx/pulls/2060"}},"in_reply_to_id":156797092},"pull_request":{"url":"https://api.github.com/repos/openucx/ucx/pulls/2060","id":157498548,"html_url":"https://github.com/openucx/ucx/pull/2060","diff_url":"https://github.com/openucx/ucx/pull/2060.diff","patch_url":"https://github.com/openucx/ucx/pull/2060.patch","issue_url":"https://api.github.com/repos/openucx/ucx/issues/2060","number":2060,"state":"open","locked":false,"title":"UCP/STREAM: optimization, avoid extra copying on \"expected\" path","user":{"login":"evgeny-leksikov","id":15216359,"avatar_url":"https://avatars3.githubusercontent.com/u/15216359?v=4","gravatar_id":"","url":"https://api.github.com/users/evgeny-leksikov","html_url":"https://github.com/evgeny-leksikov","followers_url":"https://api.github.com/users/evgeny-leksikov/followers","following_url":"https://api.github.com/users/evgeny-leksikov/following{/other_user}","gists_url":"https://api.github.com/users/evgeny-leksikov/gists{/gist_id}","starred_url":"https://api.github.com/users/evgeny-leksikov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evgeny-leksikov/subscriptions","organizations_url":"https://api.github.com/users/evgeny-leksikov/orgs","repos_url":"https://api.github.com/users/evgeny-leksikov/repos","events_url":"https://api.github.com/users/evgeny-leksikov/events{/privacy}","received_events_url":"https://api.github.com/users/evgeny-leksikov/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-12-11T08:00:49Z","updated_at":"2017-12-14T06:56:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5bc7da5c40e8063dfeafec394ba4163fa828c132","assignee":null,"assignees":[],"requested_reviewers":[{"login":"alex-mikheev","id":8735389,"avatar_url":"https://avatars3.githubusercontent.com/u/8735389?v=4","gravatar_id":"","url":"https://api.github.com/users/alex-mikheev","html_url":"https://github.com/alex-mikheev","followers_url":"https://api.github.com/users/alex-mikheev/followers","following_url":"https://api.github.com/users/alex-mikheev/following{/other_user}","gists_url":"https://api.github.com/users/alex-mikheev/gists{/gist_id}","starred_url":"https://api.github.com/users/alex-mikheev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alex-mikheev/subscriptions","organizations_url":"https://api.github.com/users/alex-mikheev/orgs","repos_url":"https://api.github.com/users/alex-mikheev/repos","events_url":"https://api.github.com/users/alex-mikheev/events{/privacy}","received_events_url":"https://api.github.com/users/alex-mikheev/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/openucx/ucx/pulls/2060/commits","review_comments_url":"https://api.github.com/repos/openucx/ucx/pulls/2060/comments","review_comment_url":"https://api.github.com/repos/openucx/ucx/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openucx/ucx/issues/2060/comments","statuses_url":"https://api.github.com/repos/openucx/ucx/statuses/dc2fd3170a4991269778d230b075ba509245f250","head":{"label":"evgeny-leksikov:ucp_stream_am_opt_2","ref":"ucp_stream_am_opt_2","sha":"dc2fd3170a4991269778d230b075ba509245f250","user":{"login":"evgeny-leksikov","id":15216359,"avatar_url":"https://avatars3.githubusercontent.com/u/15216359?v=4","gravatar_id":"","url":"https://api.github.com/users/evgeny-leksikov","html_url":"https://github.com/evgeny-leksikov","followers_url":"https://api.github.com/users/evgeny-leksikov/followers","following_url":"https://api.github.com/users/evgeny-leksikov/following{/other_user}","gists_url":"https://api.github.com/users/evgeny-leksikov/gists{/gist_id}","starred_url":"https://api.github.com/users/evgeny-leksikov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evgeny-leksikov/subscriptions","organizations_url":"https://api.github.com/users/evgeny-leksikov/orgs","repos_url":"https://api.github.com/users/evgeny-leksikov/repos","events_url":"https://api.github.com/users/evgeny-leksikov/events{/privacy}","received_events_url":"https://api.github.com/users/evgeny-leksikov/received_events","type":"User","site_admin":false},"repo":{"id":77319416,"name":"ucx","full_name":"evgeny-leksikov/ucx","owner":{"login":"evgeny-leksikov","id":15216359,"avatar_url":"https://avatars3.githubusercontent.com/u/15216359?v=4","gravatar_id":"","url":"https://api.github.com/users/evgeny-leksikov","html_url":"https://github.com/evgeny-leksikov","followers_url":"https://api.github.com/users/evgeny-leksikov/followers","following_url":"https://api.github.com/users/evgeny-leksikov/following{/other_user}","gists_url":"https://api.github.com/users/evgeny-leksikov/gists{/gist_id}","starred_url":"https://api.github.com/users/evgeny-leksikov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evgeny-leksikov/subscriptions","organizations_url":"https://api.github.com/users/evgeny-leksikov/orgs","repos_url":"https://api.github.com/users/evgeny-leksikov/repos","events_url":"https://api.github.com/users/evgeny-leksikov/events{/privacy}","received_events_url":"https://api.github.com/users/evgeny-leksikov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/evgeny-leksikov/ucx","description":"Unified Communication X  (mailing list - https://elist.ornl.gov/mailman/listinfo/ucx-group): ","fork":true,"url":"https://api.github.com/repos/evgeny-leksikov/ucx","forks_url":"https://api.github.com/repos/evgeny-leksikov/ucx/forks","keys_url":"https://api.github.com/repos/evgeny-leksikov/ucx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/evgeny-leksikov/ucx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/evgeny-leksikov/ucx/teams","hooks_url":"https://api.github.com/repos/evgeny-leksikov/ucx/hooks","issue_events_url":"https://api.github.com/repos/evgeny-leksikov/ucx/issues/events{/number}","events_url":"https://api.github.com/repos/evgeny-leksikov/ucx/events","assignees_url":"https://api.github.com/repos/evgeny-leksikov/ucx/assignees{/user}","branches_url":"https://api.github.com/repos/evgeny-leksikov/ucx/branches{/branch}","tags_url":"https://api.github.com/repos/evgeny-leksikov/ucx/tags","blobs_url":"https://api.github.com/repos/evgeny-leksikov/ucx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/evgeny-leksikov/ucx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/evgeny-leksikov/ucx/git/refs{/sha}","trees_url":"https://api.github.com/repos/evgeny-leksikov/ucx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/evgeny-leksikov/ucx/statuses/{sha}","languages_url":"https://api.github.com/repos/evgeny-leksikov/ucx/languages","stargazers_url":"https://api.github.com/repos/evgeny-leksikov/ucx/stargazers","contributors_url":"https://api.github.com/repos/evgeny-leksikov/ucx/contributors","subscribers_url":"https://api.github.com/repos/evgeny-leksikov/ucx/subscribers","subscription_url":"https://api.github.com/repos/evgeny-leksikov/ucx/subscription","commits_url":"https://api.github.com/repos/evgeny-leksikov/ucx/commits{/sha}","git_commits_url":"https://api.github.com/repos/evgeny-leksikov/ucx/git/commits{/sha}","comments_url":"https://api.github.com/repos/evgeny-leksikov/ucx/comments{/number}","issue_comment_url":"https://api.github.com/repos/evgeny-leksikov/ucx/issues/comments{/number}","contents_url":"https://api.github.com/repos/evgeny-leksikov/ucx/contents/{+path}","compare_url":"https://api.github.com/repos/evgeny-leksikov/ucx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/evgeny-leksikov/ucx/merges","archive_url":"https://api.github.com/repos/evgeny-leksikov/ucx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/evgeny-leksikov/ucx/downloads","issues_url":"https://api.github.com/repos/evgeny-leksikov/ucx/issues{/number}","pulls_url":"https://api.github.com/repos/evgeny-leksikov/ucx/pulls{/number}","milestones_url":"https://api.github.com/repos/evgeny-leksikov/ucx/milestones{/number}","notifications_url":"https://api.github.com/repos/evgeny-leksikov/ucx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/evgeny-leksikov/ucx/labels{/name}","releases_url":"https://api.github.com/repos/evgeny-leksikov/ucx/releases{/id}","deployments_url":"https://api.github.com/repos/evgeny-leksikov/ucx/deployments","created_at":"2016-12-25T09:34:08Z","updated_at":"2016-12-25T09:34:12Z","pushed_at":"2017-12-13T15:53:38Z","git_url":"git://github.com/evgeny-leksikov/ucx.git","ssh_url":"git@github.com:evgeny-leksikov/ucx.git","clone_url":"https://github.com/evgeny-leksikov/ucx.git","svn_url":"https://github.com/evgeny-leksikov/ucx","homepage":"http://www.openucx.org","size":10296,"stargazers_count":0,"watchers_count":0,"language":"C","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":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"openucx:master","ref":"master","sha":"5a1682d04c91574678ebff91ceb0ebf96ea23378","user":{"login":"openucx","id":13118737,"avatar_url":"https://avatars2.githubusercontent.com/u/13118737?v=4","gravatar_id":"","url":"https://api.github.com/users/openucx","html_url":"https://github.com/openucx","followers_url":"https://api.github.com/users/openucx/followers","following_url":"https://api.github.com/users/openucx/following{/other_user}","gists_url":"https://api.github.com/users/openucx/gists{/gist_id}","starred_url":"https://api.github.com/users/openucx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openucx/subscriptions","organizations_url":"https://api.github.com/users/openucx/orgs","repos_url":"https://api.github.com/users/openucx/repos","events_url":"https://api.github.com/users/openucx/events{/privacy}","received_events_url":"https://api.github.com/users/openucx/received_events","type":"Organization","site_admin":false},"repo":{"id":25379390,"name":"ucx","full_name":"openucx/ucx","owner":{"login":"openucx","id":13118737,"avatar_url":"https://avatars2.githubusercontent.com/u/13118737?v=4","gravatar_id":"","url":"https://api.github.com/users/openucx","html_url":"https://github.com/openucx","followers_url":"https://api.github.com/users/openucx/followers","following_url":"https://api.github.com/users/openucx/following{/other_user}","gists_url":"https://api.github.com/users/openucx/gists{/gist_id}","starred_url":"https://api.github.com/users/openucx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openucx/subscriptions","organizations_url":"https://api.github.com/users/openucx/orgs","repos_url":"https://api.github.com/users/openucx/repos","events_url":"https://api.github.com/users/openucx/events{/privacy}","received_events_url":"https://api.github.com/users/openucx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openucx/ucx","description":"Unified Communication X  (mailing list - https://elist.ornl.gov/mailman/listinfo/ucx-group): ","fork":false,"url":"https://api.github.com/repos/openucx/ucx","forks_url":"https://api.github.com/repos/openucx/ucx/forks","keys_url":"https://api.github.com/repos/openucx/ucx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openucx/ucx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openucx/ucx/teams","hooks_url":"https://api.github.com/repos/openucx/ucx/hooks","issue_events_url":"https://api.github.com/repos/openucx/ucx/issues/events{/number}","events_url":"https://api.github.com/repos/openucx/ucx/events","assignees_url":"https://api.github.com/repos/openucx/ucx/assignees{/user}","branches_url":"https://api.github.com/repos/openucx/ucx/branches{/branch}","tags_url":"https://api.github.com/repos/openucx/ucx/tags","blobs_url":"https://api.github.com/repos/openucx/ucx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openucx/ucx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openucx/ucx/git/refs{/sha}","trees_url":"https://api.github.com/repos/openucx/ucx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openucx/ucx/statuses/{sha}","languages_url":"https://api.github.com/repos/openucx/ucx/languages","stargazers_url":"https://api.github.com/repos/openucx/ucx/stargazers","contributors_url":"https://api.github.com/repos/openucx/ucx/contributors","subscribers_url":"https://api.github.com/repos/openucx/ucx/subscribers","subscription_url":"https://api.github.com/repos/openucx/ucx/subscription","commits_url":"https://api.github.com/repos/openucx/ucx/commits{/sha}","git_commits_url":"https://api.github.com/repos/openucx/ucx/git/commits{/sha}","comments_url":"https://api.github.com/repos/openucx/ucx/comments{/number}","issue_comment_url":"https://api.github.com/repos/openucx/ucx/issues/comments{/number}","contents_url":"https://api.github.com/repos/openucx/ucx/contents/{+path}","compare_url":"https://api.github.com/repos/openucx/ucx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openucx/ucx/merges","archive_url":"https://api.github.com/repos/openucx/ucx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openucx/ucx/downloads","issues_url":"https://api.github.com/repos/openucx/ucx/issues{/number}","pulls_url":"https://api.github.com/repos/openucx/ucx/pulls{/number}","milestones_url":"https://api.github.com/repos/openucx/ucx/milestones{/number}","notifications_url":"https://api.github.com/repos/openucx/ucx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openucx/ucx/labels{/name}","releases_url":"https://api.github.com/repos/openucx/ucx/releases{/id}","deployments_url":"https://api.github.com/repos/openucx/ucx/deployments","created_at":"2014-10-17T22:17:24Z","updated_at":"2017-12-11T02:28:51Z","pushed_at":"2017-12-13T21:23:21Z","git_url":"git://github.com/openucx/ucx.git","ssh_url":"git@github.com:openucx/ucx.git","clone_url":"https://github.com/openucx/ucx.git","svn_url":"https://github.com/openucx/ucx","homepage":"http://www.openucx.org","size":10488,"stargazers_count":89,"watchers_count":89,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":66,"mirror_url":null,"archived":false,"open_issues_count":137,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":66,"open_issues":137,"watchers":89,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openucx/ucx/pulls/2060"},"html":{"href":"https://github.com/openucx/ucx/pull/2060"},"issue":{"href":"https://api.github.com/repos/openucx/ucx/issues/2060"},"comments":{"href":"https://api.github.com/repos/openucx/ucx/issues/2060/comments"},"review_comments":{"href":"https://api.github.com/repos/openucx/ucx/pulls/2060/comments"},"review_comment":{"href":"https://api.github.com/repos/openucx/ucx/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openucx/ucx/pulls/2060/commits"},"statuses":{"href":"https://api.github.com/repos/openucx/ucx/statuses/dc2fd3170a4991269778d230b075ba509245f250"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"evgeny-leksikov"}}