{"action":"created","comment":{"url":"https://api.github.com/repos/servo/ipc-channel/pulls/comments/62084706","id":62084706,"diff_hunk":"@@ -30,7 +30,8 @@ const MAP_FAILED: *mut u8 = (!0usize) as *mut u8;\n \n // The value Linux returns for SO_SNDBUF\n // is not the size we are actually allowed to use...\n-const RESERVED_SIZE: usize = 256;\n+// Empirically, we have to deduct 32 bytes from that.\n+const RESERVED_SIZE: usize = 32;","path":"platform/linux/mod.rs","position":null,"original_position":6,"commit_id":"24c9b4f1067b9ede2a9f486890848f94d829f1b9","original_commit_id":"eb6d54a3d525d9b198104b8f69f7d1807c4cbcb7","user":{"login":"antrik","id":19555,"avatar_url":"https://avatars.githubusercontent.com/u/19555?v=3","gravatar_id":"","url":"https://api.github.com/users/antrik","html_url":"https://github.com/antrik","followers_url":"https://api.github.com/users/antrik/followers","following_url":"https://api.github.com/users/antrik/following{/other_user}","gists_url":"https://api.github.com/users/antrik/gists{/gist_id}","starred_url":"https://api.github.com/users/antrik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antrik/subscriptions","organizations_url":"https://api.github.com/users/antrik/orgs","repos_url":"https://api.github.com/users/antrik/repos","events_url":"https://api.github.com/users/antrik/events{/privacy}","received_events_url":"https://api.github.com/users/antrik/received_events","type":"User","site_admin":false},"body":"Indeed.\r\n\r\nThe man page actually mentions the buffer being *twice* the usable size, but in reference to a different socket type. There is no documentation about this for `SOCK_SEQPACKET` as far as I'm aware.","created_at":"2016-05-04T17:57:23Z","updated_at":"2016-05-04T17:57:23Z","html_url":"https://github.com/servo/ipc-channel/pull/68#discussion_r62084706","pull_request_url":"https://api.github.com/repos/servo/ipc-channel/pulls/68","_links":{"self":{"href":"https://api.github.com/repos/servo/ipc-channel/pulls/comments/62084706"},"html":{"href":"https://github.com/servo/ipc-channel/pull/68#discussion_r62084706"},"pull_request":{"href":"https://api.github.com/repos/servo/ipc-channel/pulls/68"}}},"pull_request":{"url":"https://api.github.com/repos/servo/ipc-channel/pulls/68","id":68485742,"html_url":"https://github.com/servo/ipc-channel/pull/68","diff_url":"https://github.com/servo/ipc-channel/pull/68.diff","patch_url":"https://github.com/servo/ipc-channel/pull/68.patch","issue_url":"https://api.github.com/repos/servo/ipc-channel/issues/68","number":68,"state":"open","locked":false,"title":"Optimisations (and cleanups) of Linux backend","user":{"login":"antrik","id":19555,"avatar_url":"https://avatars.githubusercontent.com/u/19555?v=3","gravatar_id":"","url":"https://api.github.com/users/antrik","html_url":"https://github.com/antrik","followers_url":"https://api.github.com/users/antrik/followers","following_url":"https://api.github.com/users/antrik/following{/other_user}","gists_url":"https://api.github.com/users/antrik/gists{/gist_id}","starred_url":"https://api.github.com/users/antrik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antrik/subscriptions","organizations_url":"https://api.github.com/users/antrik/orgs","repos_url":"https://api.github.com/users/antrik/repos","events_url":"https://api.github.com/users/antrik/events{/privacy}","received_events_url":"https://api.github.com/users/antrik/received_events","type":"User","site_admin":false},"body":"This is a bunch of optimisations to the Linux platform code, along with various cleanups of the related code which the optimisation patches build upon.\r\n\r\nMost of the cleanups are on the `send()` side, as the `recv()` side is less affected by the optimisation changes, and thus there has been less reason to refactor the code -- some extra cleanup work would probably be in order here.\r\n\r\nThe optimisations are mostly about avoiding unnecessary copies by using scatter-gather buffers for send and receive; as well as avoiding unnecessary initialisation of receive buffers.\r\n\r\nThe results are impressive: with gains of at least 5x for large transfers of several MiB (a bit more on a modern system); >5x (on an old system) up to >10x (on a modern one) for small transfers of up to a few KiB; and more than 10x for most of the range in between -- peaking at about 12x - 13x on the old system and 20x - 21x on the modern system for medium-sized transfers of about 64 KiB up to a few hundred KiB.\r\n\r\nFor another interesting data point, the CPU usage during benchmark runs (with many iterations, to amortise the setup time) was dominated by user time (more than two thirds of total time) with the original variant; whereas the optimised variant not only further reduces system time to less then half the original value (presumably because of fewer allocations?), but also almost entirely eliminates the user time, making it pretty insignificant in the total picture now -- as it should be.\r\n\r\nOn a less scientific note, Servo built with the optimised ipc-channel doesn't seem to show undue delays any more while rendering a language selection menu. (Which requires lots of fonts to be loaded, and thus triggers heavy ipc-channel activity.)","created_at":"2016-05-01T03:12:50Z","updated_at":"2016-05-04T17:57:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e96556fb7c45904ab70fafcda377f2690e7bc476","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/servo/ipc-channel/pulls/68/commits","review_comments_url":"https://api.github.com/repos/servo/ipc-channel/pulls/68/comments","review_comment_url":"https://api.github.com/repos/servo/ipc-channel/pulls/comments{/number}","comments_url":"https://api.github.com/repos/servo/ipc-channel/issues/68/comments","statuses_url":"https://api.github.com/repos/servo/ipc-channel/statuses/24c9b4f1067b9ede2a9f486890848f94d829f1b9","head":{"label":"antrik:optimise-buffers","ref":"optimise-buffers","sha":"24c9b4f1067b9ede2a9f486890848f94d829f1b9","user":{"login":"antrik","id":19555,"avatar_url":"https://avatars.githubusercontent.com/u/19555?v=3","gravatar_id":"","url":"https://api.github.com/users/antrik","html_url":"https://github.com/antrik","followers_url":"https://api.github.com/users/antrik/followers","following_url":"https://api.github.com/users/antrik/following{/other_user}","gists_url":"https://api.github.com/users/antrik/gists{/gist_id}","starred_url":"https://api.github.com/users/antrik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antrik/subscriptions","organizations_url":"https://api.github.com/users/antrik/orgs","repos_url":"https://api.github.com/users/antrik/repos","events_url":"https://api.github.com/users/antrik/events{/privacy}","received_events_url":"https://api.github.com/users/antrik/received_events","type":"User","site_admin":false},"repo":{"id":47907924,"name":"ipc-channel","full_name":"antrik/ipc-channel","owner":{"login":"antrik","id":19555,"avatar_url":"https://avatars.githubusercontent.com/u/19555?v=3","gravatar_id":"","url":"https://api.github.com/users/antrik","html_url":"https://github.com/antrik","followers_url":"https://api.github.com/users/antrik/followers","following_url":"https://api.github.com/users/antrik/following{/other_user}","gists_url":"https://api.github.com/users/antrik/gists{/gist_id}","starred_url":"https://api.github.com/users/antrik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antrik/subscriptions","organizations_url":"https://api.github.com/users/antrik/orgs","repos_url":"https://api.github.com/users/antrik/repos","events_url":"https://api.github.com/users/antrik/events{/privacy}","received_events_url":"https://api.github.com/users/antrik/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/antrik/ipc-channel","description":"A multiprocess drop-in replacement for Rust channels","fork":true,"url":"https://api.github.com/repos/antrik/ipc-channel","forks_url":"https://api.github.com/repos/antrik/ipc-channel/forks","keys_url":"https://api.github.com/repos/antrik/ipc-channel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/antrik/ipc-channel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/antrik/ipc-channel/teams","hooks_url":"https://api.github.com/repos/antrik/ipc-channel/hooks","issue_events_url":"https://api.github.com/repos/antrik/ipc-channel/issues/events{/number}","events_url":"https://api.github.com/repos/antrik/ipc-channel/events","assignees_url":"https://api.github.com/repos/antrik/ipc-channel/assignees{/user}","branches_url":"https://api.github.com/repos/antrik/ipc-channel/branches{/branch}","tags_url":"https://api.github.com/repos/antrik/ipc-channel/tags","blobs_url":"https://api.github.com/repos/antrik/ipc-channel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/antrik/ipc-channel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/antrik/ipc-channel/git/refs{/sha}","trees_url":"https://api.github.com/repos/antrik/ipc-channel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/antrik/ipc-channel/statuses/{sha}","languages_url":"https://api.github.com/repos/antrik/ipc-channel/languages","stargazers_url":"https://api.github.com/repos/antrik/ipc-channel/stargazers","contributors_url":"https://api.github.com/repos/antrik/ipc-channel/contributors","subscribers_url":"https://api.github.com/repos/antrik/ipc-channel/subscribers","subscription_url":"https://api.github.com/repos/antrik/ipc-channel/subscription","commits_url":"https://api.github.com/repos/antrik/ipc-channel/commits{/sha}","git_commits_url":"https://api.github.com/repos/antrik/ipc-channel/git/commits{/sha}","comments_url":"https://api.github.com/repos/antrik/ipc-channel/comments{/number}","issue_comment_url":"https://api.github.com/repos/antrik/ipc-channel/issues/comments{/number}","contents_url":"https://api.github.com/repos/antrik/ipc-channel/contents/{+path}","compare_url":"https://api.github.com/repos/antrik/ipc-channel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/antrik/ipc-channel/merges","archive_url":"https://api.github.com/repos/antrik/ipc-channel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/antrik/ipc-channel/downloads","issues_url":"https://api.github.com/repos/antrik/ipc-channel/issues{/number}","pulls_url":"https://api.github.com/repos/antrik/ipc-channel/pulls{/number}","milestones_url":"https://api.github.com/repos/antrik/ipc-channel/milestones{/number}","notifications_url":"https://api.github.com/repos/antrik/ipc-channel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/antrik/ipc-channel/labels{/name}","releases_url":"https://api.github.com/repos/antrik/ipc-channel/releases{/id}","deployments_url":"https://api.github.com/repos/antrik/ipc-channel/deployments","created_at":"2015-12-13T05:51:19Z","updated_at":"2016-04-22T14:21:12Z","pushed_at":"2016-05-03T23:38:28Z","git_url":"git://github.com/antrik/ipc-channel.git","ssh_url":"git@github.com:antrik/ipc-channel.git","clone_url":"https://github.com/antrik/ipc-channel.git","svn_url":"https://github.com/antrik/ipc-channel","homepage":"","size":337,"stargazers_count":0,"watchers_count":0,"language":"Rust","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":"servo:master","ref":"master","sha":"e43fb22c431740a9bc54ce96caebd0e67d1a0586","user":{"login":"servo","id":2566135,"avatar_url":"https://avatars.githubusercontent.com/u/2566135?v=3","gravatar_id":"","url":"https://api.github.com/users/servo","html_url":"https://github.com/servo","followers_url":"https://api.github.com/users/servo/followers","following_url":"https://api.github.com/users/servo/following{/other_user}","gists_url":"https://api.github.com/users/servo/gists{/gist_id}","starred_url":"https://api.github.com/users/servo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/servo/subscriptions","organizations_url":"https://api.github.com/users/servo/orgs","repos_url":"https://api.github.com/users/servo/repos","events_url":"https://api.github.com/users/servo/events{/privacy}","received_events_url":"https://api.github.com/users/servo/received_events","type":"Organization","site_admin":false},"repo":{"id":37943142,"name":"ipc-channel","full_name":"servo/ipc-channel","owner":{"login":"servo","id":2566135,"avatar_url":"https://avatars.githubusercontent.com/u/2566135?v=3","gravatar_id":"","url":"https://api.github.com/users/servo","html_url":"https://github.com/servo","followers_url":"https://api.github.com/users/servo/followers","following_url":"https://api.github.com/users/servo/following{/other_user}","gists_url":"https://api.github.com/users/servo/gists{/gist_id}","starred_url":"https://api.github.com/users/servo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/servo/subscriptions","organizations_url":"https://api.github.com/users/servo/orgs","repos_url":"https://api.github.com/users/servo/repos","events_url":"https://api.github.com/users/servo/events{/privacy}","received_events_url":"https://api.github.com/users/servo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/servo/ipc-channel","description":"A multiprocess drop-in replacement for Rust channels","fork":false,"url":"https://api.github.com/repos/servo/ipc-channel","forks_url":"https://api.github.com/repos/servo/ipc-channel/forks","keys_url":"https://api.github.com/repos/servo/ipc-channel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/servo/ipc-channel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/servo/ipc-channel/teams","hooks_url":"https://api.github.com/repos/servo/ipc-channel/hooks","issue_events_url":"https://api.github.com/repos/servo/ipc-channel/issues/events{/number}","events_url":"https://api.github.com/repos/servo/ipc-channel/events","assignees_url":"https://api.github.com/repos/servo/ipc-channel/assignees{/user}","branches_url":"https://api.github.com/repos/servo/ipc-channel/branches{/branch}","tags_url":"https://api.github.com/repos/servo/ipc-channel/tags","blobs_url":"https://api.github.com/repos/servo/ipc-channel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/servo/ipc-channel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/servo/ipc-channel/git/refs{/sha}","trees_url":"https://api.github.com/repos/servo/ipc-channel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/servo/ipc-channel/statuses/{sha}","languages_url":"https://api.github.com/repos/servo/ipc-channel/languages","stargazers_url":"https://api.github.com/repos/servo/ipc-channel/stargazers","contributors_url":"https://api.github.com/repos/servo/ipc-channel/contributors","subscribers_url":"https://api.github.com/repos/servo/ipc-channel/subscribers","subscription_url":"https://api.github.com/repos/servo/ipc-channel/subscription","commits_url":"https://api.github.com/repos/servo/ipc-channel/commits{/sha}","git_commits_url":"https://api.github.com/repos/servo/ipc-channel/git/commits{/sha}","comments_url":"https://api.github.com/repos/servo/ipc-channel/comments{/number}","issue_comment_url":"https://api.github.com/repos/servo/ipc-channel/issues/comments{/number}","contents_url":"https://api.github.com/repos/servo/ipc-channel/contents/{+path}","compare_url":"https://api.github.com/repos/servo/ipc-channel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/servo/ipc-channel/merges","archive_url":"https://api.github.com/repos/servo/ipc-channel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/servo/ipc-channel/downloads","issues_url":"https://api.github.com/repos/servo/ipc-channel/issues{/number}","pulls_url":"https://api.github.com/repos/servo/ipc-channel/pulls{/number}","milestones_url":"https://api.github.com/repos/servo/ipc-channel/milestones{/number}","notifications_url":"https://api.github.com/repos/servo/ipc-channel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/servo/ipc-channel/labels{/name}","releases_url":"https://api.github.com/repos/servo/ipc-channel/releases{/id}","deployments_url":"https://api.github.com/repos/servo/ipc-channel/deployments","created_at":"2015-06-23T20:28:18Z","updated_at":"2016-04-28T22:35:03Z","pushed_at":"2016-05-04T15:50:41Z","git_url":"git://github.com/servo/ipc-channel.git","ssh_url":"git@github.com:servo/ipc-channel.git","clone_url":"https://github.com/servo/ipc-channel.git","svn_url":"https://github.com/servo/ipc-channel","homepage":"","size":338,"stargazers_count":98,"watchers_count":98,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":10,"forks":17,"open_issues":10,"watchers":98,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/servo/ipc-channel/pulls/68"},"html":{"href":"https://github.com/servo/ipc-channel/pull/68"},"issue":{"href":"https://api.github.com/repos/servo/ipc-channel/issues/68"},"comments":{"href":"https://api.github.com/repos/servo/ipc-channel/issues/68/comments"},"review_comments":{"href":"https://api.github.com/repos/servo/ipc-channel/pulls/68/comments"},"review_comment":{"href":"https://api.github.com/repos/servo/ipc-channel/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/servo/ipc-channel/pulls/68/commits"},"statuses":{"href":"https://api.github.com/repos/servo/ipc-channel/statuses/24c9b4f1067b9ede2a9f486890848f94d829f1b9"}}}}