{"action":"created","comment":{"url":"https://api.github.com/repos/interiorem/elliptics/pulls/comments/68919920","id":68919920,"diff_hunk":"@@ -747,95 +748,206 @@ struct iterated_key_info {\n };\n \n typedef std::function<int (const iterated_key_info &info)> iterator_callback;\n+typedef std::function<int (std::shared_ptr<iterated_key_info> info)> iterator_server_send_callback;\n \n-static iterator_callback make_iterator_server_send_callback(eblob_backend_config *c, dnet_net_state *st,\n-                                                            dnet_cmd *cmd,\n-                                                            ioremap::elliptics::dnet_server_send_request &request,\n-                                                            uint64_t iterator_id,\n-                                                            uint64_t &counter) {\n+/*\n+ * congestion_control_monitor is used for limiting amount of data being sent to a remote backend.\n+ */\n+class congestion_control_monitor\n+{\n+public:\n+\t/*!\n+\t * Constructor: initializes internal state properly.\n+\t \\a start_batch_size - maximum amount of data being sent as a first batch\n+\t \\a batch_timeout_msec - batch timeout in milliseconds\n+\t */\n+\tcongestion_control_monitor(uint64_t start_batch_size, int batch_timeout_msec)\n+\t: m_start_batch_size(start_batch_size), m_batch_size(m_start_batch_size),\n+\t m_bytes_pending(0), m_bytes_processed(0),\n+\t m_batch_timeout_msec(batch_timeout_msec),\n+\t m_need_start_time(true) {\n+\t}\n+\n+\t/*!\n+\t * Waits until batch had any space available, then increments\n+\t * number of pending bytes in the batch.\n+\t */\n+\tvoid add_bytes(uint64_t bytes) {\n+\t\tstd::unique_lock<std::mutex> lock{m_mutex};\n+\n+\t\twhile (is_batch_full()) {\n+\t\t\tm_cond.wait(lock);\n+\t\t}\n+\t\tm_bytes_pending += bytes;\n+\n+\t\tif (m_need_start_time) {\n+\t\t\tgettimeofday(&m_batch_start_time, nullptr);\n+\t\t\tm_need_start_time = false;\n+\t\t}\n+\t}\n+\n+\t/*!\n+\t * Decrements number of pending bytes in the batch and measures\n+\t * elapsed time of processing of the batch for either increasing or decreasing size of\n+\t * the batch.\n+\t */\n+\tvoid remove_bytes(uint64_t bytes) {\n+\t\tstd::unique_lock<std::mutex> lock{m_mutex};\n+\n+\t\tm_bytes_processed += bytes;\n+\n+\t\tif (m_bytes_processed >= m_batch_size) {\n+\t\t\tm_bytes_processed -= m_batch_size;\n+\n+\t\t\tstruct timeval tv;\n+\t\t\tgettimeofday(&tv, nullptr);\n+\t\t\tconst int64_t elapsed = static_cast<int64_t>((tv.tv_sec - m_batch_start_time.tv_sec) * 1000 +","path":"example/eblob_backend.cpp","position":70,"original_position":70,"commit_id":"5f1c5e092046a547079f6c008ba9dabbf0e1d9db","original_commit_id":"5f1c5e092046a547079f6c008ba9dabbf0e1d9db","user":{"login":"shaitan","id":446423,"avatar_url":"https://avatars.githubusercontent.com/u/446423?v=3","gravatar_id":"","url":"https://api.github.com/users/shaitan","html_url":"https://github.com/shaitan","followers_url":"https://api.github.com/users/shaitan/followers","following_url":"https://api.github.com/users/shaitan/following{/other_user}","gists_url":"https://api.github.com/users/shaitan/gists{/gist_id}","starred_url":"https://api.github.com/users/shaitan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shaitan/subscriptions","organizations_url":"https://api.github.com/users/shaitan/orgs","repos_url":"https://api.github.com/users/shaitan/repos","events_url":"https://api.github.com/users/shaitan/events{/privacy}","received_events_url":"https://api.github.com/users/shaitan/received_events","type":"User","site_admin":false},"body":"Why don't you use `timersub` here?","created_at":"2016-06-29T10:08:29Z","updated_at":"2016-06-29T10:08:29Z","html_url":"https://github.com/interiorem/elliptics/pull/45#discussion_r68919920","pull_request_url":"https://api.github.com/repos/interiorem/elliptics/pulls/45","_links":{"self":{"href":"https://api.github.com/repos/interiorem/elliptics/pulls/comments/68919920"},"html":{"href":"https://github.com/interiorem/elliptics/pull/45#discussion_r68919920"},"pull_request":{"href":"https://api.github.com/repos/interiorem/elliptics/pulls/45"}}},"pull_request":{"url":"https://api.github.com/repos/interiorem/elliptics/pulls/45","id":75226613,"html_url":"https://github.com/interiorem/elliptics/pull/45","diff_url":"https://github.com/interiorem/elliptics/pull/45.diff","patch_url":"https://github.com/interiorem/elliptics/pull/45.patch","issue_url":"https://api.github.com/repos/interiorem/elliptics/issues/45","number":45,"state":"open","locked":false,"title":"server-send: use congestion_control_monitor for async writes with dyn…","user":{"login":"abudnik","id":1283969,"avatar_url":"https://avatars.githubusercontent.com/u/1283969?v=3","gravatar_id":"","url":"https://api.github.com/users/abudnik","html_url":"https://github.com/abudnik","followers_url":"https://api.github.com/users/abudnik/followers","following_url":"https://api.github.com/users/abudnik/following{/other_user}","gists_url":"https://api.github.com/users/abudnik/gists{/gist_id}","starred_url":"https://api.github.com/users/abudnik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abudnik/subscriptions","organizations_url":"https://api.github.com/users/abudnik/orgs","repos_url":"https://api.github.com/users/abudnik/repos","events_url":"https://api.github.com/users/abudnik/events{/privacy}","received_events_url":"https://api.github.com/users/abudnik/received_events","type":"User","site_admin":false},"body":"…amic batch size\r\n\r\n**DO NOT MERGE**","created_at":"2016-06-26T10:33:41Z","updated_at":"2016-06-29T10:08:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"edd9e7df4097d9690c37d03f7c4256688094487c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/interiorem/elliptics/pulls/45/commits","review_comments_url":"https://api.github.com/repos/interiorem/elliptics/pulls/45/comments","review_comment_url":"https://api.github.com/repos/interiorem/elliptics/pulls/comments{/number}","comments_url":"https://api.github.com/repos/interiorem/elliptics/issues/45/comments","statuses_url":"https://api.github.com/repos/interiorem/elliptics/statuses/5f1c5e092046a547079f6c008ba9dabbf0e1d9db","head":{"label":"abudnik:new_send","ref":"new_send","sha":"5f1c5e092046a547079f6c008ba9dabbf0e1d9db","user":{"login":"abudnik","id":1283969,"avatar_url":"https://avatars.githubusercontent.com/u/1283969?v=3","gravatar_id":"","url":"https://api.github.com/users/abudnik","html_url":"https://github.com/abudnik","followers_url":"https://api.github.com/users/abudnik/followers","following_url":"https://api.github.com/users/abudnik/following{/other_user}","gists_url":"https://api.github.com/users/abudnik/gists{/gist_id}","starred_url":"https://api.github.com/users/abudnik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abudnik/subscriptions","organizations_url":"https://api.github.com/users/abudnik/orgs","repos_url":"https://api.github.com/users/abudnik/repos","events_url":"https://api.github.com/users/abudnik/events{/privacy}","received_events_url":"https://api.github.com/users/abudnik/received_events","type":"User","site_admin":false},"repo":{"id":27128794,"name":"elliptics","full_name":"abudnik/elliptics","owner":{"login":"abudnik","id":1283969,"avatar_url":"https://avatars.githubusercontent.com/u/1283969?v=3","gravatar_id":"","url":"https://api.github.com/users/abudnik","html_url":"https://github.com/abudnik","followers_url":"https://api.github.com/users/abudnik/followers","following_url":"https://api.github.com/users/abudnik/following{/other_user}","gists_url":"https://api.github.com/users/abudnik/gists{/gist_id}","starred_url":"https://api.github.com/users/abudnik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abudnik/subscriptions","organizations_url":"https://api.github.com/users/abudnik/orgs","repos_url":"https://api.github.com/users/abudnik/repos","events_url":"https://api.github.com/users/abudnik/events{/privacy}","received_events_url":"https://api.github.com/users/abudnik/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/abudnik/elliptics","description":"Distributed hashtable storage","fork":true,"url":"https://api.github.com/repos/abudnik/elliptics","forks_url":"https://api.github.com/repos/abudnik/elliptics/forks","keys_url":"https://api.github.com/repos/abudnik/elliptics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/abudnik/elliptics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/abudnik/elliptics/teams","hooks_url":"https://api.github.com/repos/abudnik/elliptics/hooks","issue_events_url":"https://api.github.com/repos/abudnik/elliptics/issues/events{/number}","events_url":"https://api.github.com/repos/abudnik/elliptics/events","assignees_url":"https://api.github.com/repos/abudnik/elliptics/assignees{/user}","branches_url":"https://api.github.com/repos/abudnik/elliptics/branches{/branch}","tags_url":"https://api.github.com/repos/abudnik/elliptics/tags","blobs_url":"https://api.github.com/repos/abudnik/elliptics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/abudnik/elliptics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/abudnik/elliptics/git/refs{/sha}","trees_url":"https://api.github.com/repos/abudnik/elliptics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/abudnik/elliptics/statuses/{sha}","languages_url":"https://api.github.com/repos/abudnik/elliptics/languages","stargazers_url":"https://api.github.com/repos/abudnik/elliptics/stargazers","contributors_url":"https://api.github.com/repos/abudnik/elliptics/contributors","subscribers_url":"https://api.github.com/repos/abudnik/elliptics/subscribers","subscription_url":"https://api.github.com/repos/abudnik/elliptics/subscription","commits_url":"https://api.github.com/repos/abudnik/elliptics/commits{/sha}","git_commits_url":"https://api.github.com/repos/abudnik/elliptics/git/commits{/sha}","comments_url":"https://api.github.com/repos/abudnik/elliptics/comments{/number}","issue_comment_url":"https://api.github.com/repos/abudnik/elliptics/issues/comments{/number}","contents_url":"https://api.github.com/repos/abudnik/elliptics/contents/{+path}","compare_url":"https://api.github.com/repos/abudnik/elliptics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/abudnik/elliptics/merges","archive_url":"https://api.github.com/repos/abudnik/elliptics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/abudnik/elliptics/downloads","issues_url":"https://api.github.com/repos/abudnik/elliptics/issues{/number}","pulls_url":"https://api.github.com/repos/abudnik/elliptics/pulls{/number}","milestones_url":"https://api.github.com/repos/abudnik/elliptics/milestones{/number}","notifications_url":"https://api.github.com/repos/abudnik/elliptics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/abudnik/elliptics/labels{/name}","releases_url":"https://api.github.com/repos/abudnik/elliptics/releases{/id}","deployments_url":"https://api.github.com/repos/abudnik/elliptics/deployments","created_at":"2014-11-25T14:13:07Z","updated_at":"2016-01-12T10:42:11Z","pushed_at":"2016-06-28T18:09:42Z","git_url":"git://github.com/abudnik/elliptics.git","ssh_url":"git@github.com:abudnik/elliptics.git","clone_url":"https://github.com/abudnik/elliptics.git","svn_url":"https://github.com/abudnik/elliptics","homepage":null,"size":19882,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"interiorem:master","ref":"master","sha":"8416d077a9ef1ce4afa6cc33049243cefd87a030","user":{"login":"interiorem","id":17122620,"avatar_url":"https://avatars.githubusercontent.com/u/17122620?v=3","gravatar_id":"","url":"https://api.github.com/users/interiorem","html_url":"https://github.com/interiorem","followers_url":"https://api.github.com/users/interiorem/followers","following_url":"https://api.github.com/users/interiorem/following{/other_user}","gists_url":"https://api.github.com/users/interiorem/gists{/gist_id}","starred_url":"https://api.github.com/users/interiorem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/interiorem/subscriptions","organizations_url":"https://api.github.com/users/interiorem/orgs","repos_url":"https://api.github.com/users/interiorem/repos","events_url":"https://api.github.com/users/interiorem/events{/privacy}","received_events_url":"https://api.github.com/users/interiorem/received_events","type":"Organization","site_admin":false},"repo":{"id":51368986,"name":"elliptics","full_name":"interiorem/elliptics","owner":{"login":"interiorem","id":17122620,"avatar_url":"https://avatars.githubusercontent.com/u/17122620?v=3","gravatar_id":"","url":"https://api.github.com/users/interiorem","html_url":"https://github.com/interiorem","followers_url":"https://api.github.com/users/interiorem/followers","following_url":"https://api.github.com/users/interiorem/following{/other_user}","gists_url":"https://api.github.com/users/interiorem/gists{/gist_id}","starred_url":"https://api.github.com/users/interiorem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/interiorem/subscriptions","organizations_url":"https://api.github.com/users/interiorem/orgs","repos_url":"https://api.github.com/users/interiorem/repos","events_url":"https://api.github.com/users/interiorem/events{/privacy}","received_events_url":"https://api.github.com/users/interiorem/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/interiorem/elliptics","description":"Distributed storage for medium and large objects with streaming support","fork":true,"url":"https://api.github.com/repos/interiorem/elliptics","forks_url":"https://api.github.com/repos/interiorem/elliptics/forks","keys_url":"https://api.github.com/repos/interiorem/elliptics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/interiorem/elliptics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/interiorem/elliptics/teams","hooks_url":"https://api.github.com/repos/interiorem/elliptics/hooks","issue_events_url":"https://api.github.com/repos/interiorem/elliptics/issues/events{/number}","events_url":"https://api.github.com/repos/interiorem/elliptics/events","assignees_url":"https://api.github.com/repos/interiorem/elliptics/assignees{/user}","branches_url":"https://api.github.com/repos/interiorem/elliptics/branches{/branch}","tags_url":"https://api.github.com/repos/interiorem/elliptics/tags","blobs_url":"https://api.github.com/repos/interiorem/elliptics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/interiorem/elliptics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/interiorem/elliptics/git/refs{/sha}","trees_url":"https://api.github.com/repos/interiorem/elliptics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/interiorem/elliptics/statuses/{sha}","languages_url":"https://api.github.com/repos/interiorem/elliptics/languages","stargazers_url":"https://api.github.com/repos/interiorem/elliptics/stargazers","contributors_url":"https://api.github.com/repos/interiorem/elliptics/contributors","subscribers_url":"https://api.github.com/repos/interiorem/elliptics/subscribers","subscription_url":"https://api.github.com/repos/interiorem/elliptics/subscription","commits_url":"https://api.github.com/repos/interiorem/elliptics/commits{/sha}","git_commits_url":"https://api.github.com/repos/interiorem/elliptics/git/commits{/sha}","comments_url":"https://api.github.com/repos/interiorem/elliptics/comments{/number}","issue_comment_url":"https://api.github.com/repos/interiorem/elliptics/issues/comments{/number}","contents_url":"https://api.github.com/repos/interiorem/elliptics/contents/{+path}","compare_url":"https://api.github.com/repos/interiorem/elliptics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/interiorem/elliptics/merges","archive_url":"https://api.github.com/repos/interiorem/elliptics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/interiorem/elliptics/downloads","issues_url":"https://api.github.com/repos/interiorem/elliptics/issues{/number}","pulls_url":"https://api.github.com/repos/interiorem/elliptics/pulls{/number}","milestones_url":"https://api.github.com/repos/interiorem/elliptics/milestones{/number}","notifications_url":"https://api.github.com/repos/interiorem/elliptics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/interiorem/elliptics/labels{/name}","releases_url":"https://api.github.com/repos/interiorem/elliptics/releases{/id}","deployments_url":"https://api.github.com/repos/interiorem/elliptics/deployments","created_at":"2016-02-09T13:38:50Z","updated_at":"2016-05-18T15:33:06Z","pushed_at":"2016-06-28T18:09:42Z","git_url":"git://github.com/interiorem/elliptics.git","ssh_url":"git@github.com:interiorem/elliptics.git","clone_url":"https://github.com/interiorem/elliptics.git","svn_url":"https://github.com/interiorem/elliptics","homepage":"http://reverbrain.com/elliptics","size":19849,"stargazers_count":1,"watchers_count":1,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/interiorem/elliptics/pulls/45"},"html":{"href":"https://github.com/interiorem/elliptics/pull/45"},"issue":{"href":"https://api.github.com/repos/interiorem/elliptics/issues/45"},"comments":{"href":"https://api.github.com/repos/interiorem/elliptics/issues/45/comments"},"review_comments":{"href":"https://api.github.com/repos/interiorem/elliptics/pulls/45/comments"},"review_comment":{"href":"https://api.github.com/repos/interiorem/elliptics/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/interiorem/elliptics/pulls/45/commits"},"statuses":{"href":"https://api.github.com/repos/interiorem/elliptics/statuses/5f1c5e092046a547079f6c008ba9dabbf0e1d9db"}}}}
{"actor":{"display_login":"shaitan"}}