{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/17674","labels_url":"https://api.github.com/repos/docker/docker/issues/17674/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/17674/comments","events_url":"https://api.github.com/repos/docker/docker/issues/17674/events","html_url":"https://github.com/docker/docker/pull/17674","id":114949713,"number":17674,"title":"Use parallel gzip","user":{"login":"csfrancis","id":4303686,"avatar_url":"https://avatars.githubusercontent.com/u/4303686?v=3","gravatar_id":"","url":"https://api.github.com/users/csfrancis","html_url":"https://github.com/csfrancis","followers_url":"https://api.github.com/users/csfrancis/followers","following_url":"https://api.github.com/users/csfrancis/following{/other_user}","gists_url":"https://api.github.com/users/csfrancis/gists{/gist_id}","starred_url":"https://api.github.com/users/csfrancis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/csfrancis/subscriptions","organizations_url":"https://api.github.com/users/csfrancis/orgs","repos_url":"https://api.github.com/users/csfrancis/repos","events_url":"https://api.github.com/users/csfrancis/events{/privacy}","received_events_url":"https://api.github.com/users/csfrancis/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/docker/docker/labels/group/distribution","name":"group/distribution","color":"F6FBFF"},{"url":"https://api.github.com/repos/docker/docker/labels/status/1-design-review","name":"status/1-design-review","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":25,"created_at":"2015-11-04T01:37:41Z","updated_at":"2015-11-19T22:10:31Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/17674","html_url":"https://github.com/docker/docker/pull/17674","diff_url":"https://github.com/docker/docker/pull/17674.diff","patch_url":"https://github.com/docker/docker/pull/17674.patch"},"body":"/cc @burke \r\n\r\nThis replaces the use of the stdlib gzip library with @klauspost's parallel gzip library. More information can be found in this blog post by the author: https://blog.klauspost.com/optimized-gzipzip-packages-30-50-faster/.\r\n\r\nThis provides a significant speed-up when generating large-ish (1GB or so) container images for the Shopify Rails application. When setting `GOMAXPROCS` to 8, we were observed a 70% performance improvement with `docker push`.\r\n\r\nBefore:\r\n```\r\nNov  4 00:39:21.195:\t++ docker push registry.xxx.xxx/build-intermediate-shopify-ci-branches:49ecb981-2b55e03c\r\nNov  4 00:39:21.296:\tThe push refers to a repository [registry.xxx.xxx/build-intermediate-shopify-ci-branches] (len: 1)\r\nNov  4 00:39:21.314:\t634c07f5a0c5: Preparing\r\nNov  4 00:39:21.414:\t634c07f5a0c5: Pushing\r\nNov  4 00:41:19.541:\t634c07f5a0c5: Pushed\r\nNov  4 00:41:19.923:\t49ecb98193c3: Image already exists\r\nNov  4 00:41:20.313:\t7411b4ebe7e1: Image already exists\r\nNov  4 00:41:20.976:\t87aaf62b5b12: Image already exists\r\nNov  4 00:41:21.242:\t35c6fdcbcc02: Image already exists\r\nNov  4 00:41:21.267:\t49ecb981-2b55e03c: digest: sha256:1cdc301af17222b34d76e83d603d14bcc0bb5d52f31db6a905630267f23bd270 size: 8557\r\n```\r\n\r\nAfter:\r\n```\r\nNov  4 00:51:22.912:\t++ docker push registry.xxx.xxx/build-intermediate-shopify-ci-branches:49ecb981-1fa098cf\r\nNov  4 00:51:23.006:\tThe push refers to a repository [registry.xxx.xxx/build-intermediate-shopify-ci-branches] (len: 1)\r\nNov  4 00:51:23.025:\t857f975abc73: Preparing\r\nNov  4 00:51:23.214:\t857f975abc73: Pushing\r\nNov  4 00:52:31.623:\t857f975abc73: Pushed\r\nNov  4 00:52:31.839:\t49ecb98193c3: Image already exists\r\nNov  4 00:52:32.037:\t7411b4ebe7e1: Image already exists\r\nNov  4 00:52:32.381:\t87aaf62b5b12: Image already exists\r\nNov  4 00:52:32.748:\t35c6fdcbcc02: Image already exists\r\nNov  4 00:52:32.750:\t49ecb981-1fa098cf: digest: sha256:0a842eb5815fc1715989b4a3ad57ce926bc0edd129231218ec0ca53bc73b250a size: 8557\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/158216133","html_url":"https://github.com/docker/docker/pull/17674#issuecomment-158216133","issue_url":"https://api.github.com/repos/docker/docker/issues/17674","id":158216133,"user":{"login":"unclejack","id":1409668,"avatar_url":"https://avatars.githubusercontent.com/u/1409668?v=3","gravatar_id":"","url":"https://api.github.com/users/unclejack","html_url":"https://github.com/unclejack","followers_url":"https://api.github.com/users/unclejack/followers","following_url":"https://api.github.com/users/unclejack/following{/other_user}","gists_url":"https://api.github.com/users/unclejack/gists{/gist_id}","starred_url":"https://api.github.com/users/unclejack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unclejack/subscriptions","organizations_url":"https://api.github.com/users/unclejack/orgs","repos_url":"https://api.github.com/users/unclejack/repos","events_url":"https://api.github.com/users/unclejack/events{/privacy}","received_events_url":"https://api.github.com/users/unclejack/received_events","type":"User","site_admin":false},"created_at":"2015-11-19T22:10:30Z","updated_at":"2015-11-19T22:10:30Z","body":"This has been discussed a bit and it still seems that it might cause a lot of problems.\r\n\r\nHere are a few situations where the hashes might turn out different due to having a different resulting gzip archive for the same input data:\r\n- the code changes and the resulting archive is different for the same machine\r\n- the level of parallelism changes (via GOMAXPROCS or via the discussed parallelism option restricted to the pgzip configuration)\r\n- two different machines compress that same data, but they have different number of CPUs (if this isn't deterministic)\r\n\r\nI appreciate most optimizations and I've put countless hours into optimizing the code (as you can also find out from my history of pull requests), but this really seems to be quite dangerous without any actual real world testing in all sorts of environments.\r\n\r\nBased on previous experience with changes to the registry code and to code in general, predicting all side effects is quite difficult and something seemingly safe might come back to ruin your day, week or month.\r\n\r\nIt all boils down to figuring out if the risk of breaking things in a not very apparent way for everyone is worth making this slightly faster for those who find compression to be a bottleneck for what they're doing today. Would you prefer faster code which breaks because it can't cope with the lack of deterministic output or would you prefer more reliable code?\r\n\r\nI've tried parallel compressors a while ago and they were affecting other workloads running on the system because they could scale to a lot of CPU cores. Please keep in mind that, unlike for external compressors, there's no way to lower the process priority for some goroutines, only for the whole Docker daemon, and this means things won't be as great with this parallel gzip compression.\r\n\r\nPerhaps we should figure out how we can help @klauspost upstream his changes from [compress](https://github.com/klauspost/compress#changelog) to the stdlib. This will ensure `compress/gzip` will be faster and have better quality overall. We would also be forced to fix the issue, not just work around it.\r\n\r\nOverall, these changes could have been reasonable if we had a separate registry client sub-daemon (or process which is executed as needed) to enable resource control and if we had a way to guarantee deterministic output on all environments."}}