{"action":"created","comment":{"url":"https://api.github.com/repos/minio/minio/pulls/comments/209465484","pull_request_review_id":145484561,"id":209465484,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwOTQ2NTQ4NA==","diff_hunk":"@@ -152,8 +176,72 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req\n \t\tlength = hrange.getLength()\n \t}\n \n+\tgetObject := objectAPI.GetObject\n+\tif api.CacheAPI() != nil && !hasSSECustomerHeader(r.Header) {\n+\t\tgetObject = api.CacheAPI().GetObject\n+\t}\n+\n \tvar writer io.Writer\n-\twriter = w\n+\n+\tif objInfo.IsCompressed() {\n+\t\tvar pipeErr error\n+\n+\t\t// Defaulting the length and startOffset.\n+\t\t// Incase of range based queries, the entire data is read to the pipeWriter.\n+\t\t// So that range is set on the decompressed data.\n+\t\tsnappyStartOffset := startOffset\n+\t\tsnappyLength := length\n+\t\tlength = compressedSize\n+\t\tstartOffset = 0\n+\n+\t\t// Validate the range.\n+\t\tif hrange != nil {\n+\t\t\t// For negative length we read everything.\n+\t\t\tif snappyLength < 0 {\n+\t\t\t\tsnappyLength = actualSize - snappyStartOffset\n+\t\t\t}\n+\n+\t\t\t// Reply back invalid range if the input offset and length fall out of range.\n+\t\t\tif snappyStartOffset > actualSize || snappyStartOffset+snappyLength > actualSize {\n+\t\t\t\twriteErrorResponse(w, ErrInvalidRange, r.URL)\n+\t\t\t\treturn\n+\t\t\t}\n+\t\t}\n+\t\tobjInfo.Size = snappyLength\n+\t\tsetObjectHeaders(w, objInfo, hrange)\n+\t\tsetHeadGetRespHeaders(w, r.URL.Query())\n+\n+\t\t// Open a pipe for compression\n+\t\t// Where pipeWriter is actually passed to the getObject\n+\t\tpipeReader, pipeWriter := io.Pipe()\n+\t\tsnappyReader := snappy.NewReader(pipeReader)\n+\n+\t\tgo func() {\n+\t\t\twg.Add(1)\n+\t\t\tdefer wg.Done()\n+\t\t\tif hrange != nil {\n+\t\t\t\t// Discarding the data till the startOffset, if the range is enabled.\n+\t\t\t\t// goioutil.Discard imitates a dummy writer.\n+\t\t\t\tif _, pipeErr = io.CopyN(goioutil.Discard, snappyReader, snappyStartOffset); pipeErr != nil {","path":"cmd/object-handlers.go","position":104,"original_position":104,"commit_id":"b6f720b56d4e0f02a72772012465bb72cd04026a","original_commit_id":"b6f720b56d4e0f02a72772012465bb72cd04026a","user":{"login":"aead","id":20368805,"node_id":"MDQ6VXNlcjIwMzY4ODA1","avatar_url":"https://avatars0.githubusercontent.com/u/20368805?v=4","gravatar_id":"","url":"https://api.github.com/users/aead","html_url":"https://github.com/aead","followers_url":"https://api.github.com/users/aead/followers","following_url":"https://api.github.com/users/aead/following{/other_user}","gists_url":"https://api.github.com/users/aead/gists{/gist_id}","starred_url":"https://api.github.com/users/aead/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aead/subscriptions","organizations_url":"https://api.github.com/users/aead/orgs","repos_url":"https://api.github.com/users/aead/repos","events_url":"https://api.github.com/users/aead/events{/privacy}","received_events_url":"https://api.github.com/users/aead/received_events","type":"User","site_admin":false},"body":"My naive guess would be: `minCompressedSize(16 MB) = 786948`. The smaller `x` and the better snappy compresses the better is the approach I described with respect to read overhead. So maybe 64 KB for `x` may be reasonable size for read overhead (however I don't know the performance impact for snappy...) ","created_at":"2018-08-12T19:32:03Z","updated_at":"2018-08-12T19:32:03Z","html_url":"https://github.com/minio/minio/pull/6079#discussion_r209465484","pull_request_url":"https://api.github.com/repos/minio/minio/pulls/6079","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/minio/minio/pulls/comments/209465484"},"html":{"href":"https://github.com/minio/minio/pull/6079#discussion_r209465484"},"pull_request":{"href":"https://api.github.com/repos/minio/minio/pulls/6079"}},"in_reply_to_id":209453526},"pull_request":{"url":"https://api.github.com/repos/minio/minio/pulls/6079","id":197076146,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk3MDc2MTQ2","html_url":"https://github.com/minio/minio/pull/6079","diff_url":"https://github.com/minio/minio/pull/6079.diff","patch_url":"https://github.com/minio/minio/pull/6079.patch","issue_url":"https://api.github.com/repos/minio/minio/issues/6079","number":6079,"state":"open","locked":false,"title":"Compression in Minio","user":{"login":"Praveenrajmani","id":5410427,"node_id":"MDQ6VXNlcjU0MTA0Mjc=","avatar_url":"https://avatars0.githubusercontent.com/u/5410427?v=4","gravatar_id":"","url":"https://api.github.com/users/Praveenrajmani","html_url":"https://github.com/Praveenrajmani","followers_url":"https://api.github.com/users/Praveenrajmani/followers","following_url":"https://api.github.com/users/Praveenrajmani/following{/other_user}","gists_url":"https://api.github.com/users/Praveenrajmani/gists{/gist_id}","starred_url":"https://api.github.com/users/Praveenrajmani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Praveenrajmani/subscriptions","organizations_url":"https://api.github.com/users/Praveenrajmani/orgs","repos_url":"https://api.github.com/users/Praveenrajmani/repos","events_url":"https://api.github.com/users/Praveenrajmani/events{/privacy}","received_events_url":"https://api.github.com/users/Praveenrajmani/received_events","type":"User","site_admin":false},"body":"\r\n## Description\r\nAll the objects reaching the handler will be subjected to compression before hitting the object layer.\r\nIt adopts the streaming compression format of **golang/snappy**.\r\nFor benchmarks, hit [https://github.com/golang/snappy](url)\r\n\r\n## Motivation and Context\r\nEfficient usage of the disk space\r\n\r\n## Types of changes\r\n<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->\r\n- [ ] Bug fix (non-breaking change which fixes an issue)\r\n- [x] New feature (non-breaking change which adds functionality)\r\n- [ ] Breaking change (fix or feature that would cause existing functionality to change)\r\n\r\n## Checklist:\r\n<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->\r\n<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->\r\n- [x] My code follows the code style of this project.\r\n- [ ] My change requires a change to the documentation.\r\n- [ ] I have updated the documentation accordingly.\r\n- [ ] I have added unit tests to cover my changes.\r\n- [ ] I have added/updated functional tests in [mint](https://github.com/minio/mint). (If yes, add `mint` PR # here: )\r\n- [ ] All new and existing tests passed.","created_at":"2018-06-25T11:01:00Z","updated_at":"2018-08-12T19:32:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cb7fee4da8990147b05da9d5a816608303ce2a6e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/minio/minio/pulls/6079/commits","review_comments_url":"https://api.github.com/repos/minio/minio/pulls/6079/comments","review_comment_url":"https://api.github.com/repos/minio/minio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/minio/minio/issues/6079/comments","statuses_url":"https://api.github.com/repos/minio/minio/statuses/b6f720b56d4e0f02a72772012465bb72cd04026a","head":{"label":"Praveenrajmani:backupCompression","ref":"backupCompression","sha":"b6f720b56d4e0f02a72772012465bb72cd04026a","user":{"login":"Praveenrajmani","id":5410427,"node_id":"MDQ6VXNlcjU0MTA0Mjc=","avatar_url":"https://avatars0.githubusercontent.com/u/5410427?v=4","gravatar_id":"","url":"https://api.github.com/users/Praveenrajmani","html_url":"https://github.com/Praveenrajmani","followers_url":"https://api.github.com/users/Praveenrajmani/followers","following_url":"https://api.github.com/users/Praveenrajmani/following{/other_user}","gists_url":"https://api.github.com/users/Praveenrajmani/gists{/gist_id}","starred_url":"https://api.github.com/users/Praveenrajmani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Praveenrajmani/subscriptions","organizations_url":"https://api.github.com/users/Praveenrajmani/orgs","repos_url":"https://api.github.com/users/Praveenrajmani/repos","events_url":"https://api.github.com/users/Praveenrajmani/events{/privacy}","received_events_url":"https://api.github.com/users/Praveenrajmani/received_events","type":"User","site_admin":false},"repo":{"id":131946763,"node_id":"MDEwOlJlcG9zaXRvcnkxMzE5NDY3NjM=","name":"minio","full_name":"Praveenrajmani/minio","owner":{"login":"Praveenrajmani","id":5410427,"node_id":"MDQ6VXNlcjU0MTA0Mjc=","avatar_url":"https://avatars0.githubusercontent.com/u/5410427?v=4","gravatar_id":"","url":"https://api.github.com/users/Praveenrajmani","html_url":"https://github.com/Praveenrajmani","followers_url":"https://api.github.com/users/Praveenrajmani/followers","following_url":"https://api.github.com/users/Praveenrajmani/following{/other_user}","gists_url":"https://api.github.com/users/Praveenrajmani/gists{/gist_id}","starred_url":"https://api.github.com/users/Praveenrajmani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Praveenrajmani/subscriptions","organizations_url":"https://api.github.com/users/Praveenrajmani/orgs","repos_url":"https://api.github.com/users/Praveenrajmani/repos","events_url":"https://api.github.com/users/Praveenrajmani/events{/privacy}","received_events_url":"https://api.github.com/users/Praveenrajmani/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Praveenrajmani/minio","description":"Minio is an open source object storage server compatible with Amazon S3 APIs","fork":true,"url":"https://api.github.com/repos/Praveenrajmani/minio","forks_url":"https://api.github.com/repos/Praveenrajmani/minio/forks","keys_url":"https://api.github.com/repos/Praveenrajmani/minio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Praveenrajmani/minio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Praveenrajmani/minio/teams","hooks_url":"https://api.github.com/repos/Praveenrajmani/minio/hooks","issue_events_url":"https://api.github.com/repos/Praveenrajmani/minio/issues/events{/number}","events_url":"https://api.github.com/repos/Praveenrajmani/minio/events","assignees_url":"https://api.github.com/repos/Praveenrajmani/minio/assignees{/user}","branches_url":"https://api.github.com/repos/Praveenrajmani/minio/branches{/branch}","tags_url":"https://api.github.com/repos/Praveenrajmani/minio/tags","blobs_url":"https://api.github.com/repos/Praveenrajmani/minio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Praveenrajmani/minio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Praveenrajmani/minio/git/refs{/sha}","trees_url":"https://api.github.com/repos/Praveenrajmani/minio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Praveenrajmani/minio/statuses/{sha}","languages_url":"https://api.github.com/repos/Praveenrajmani/minio/languages","stargazers_url":"https://api.github.com/repos/Praveenrajmani/minio/stargazers","contributors_url":"https://api.github.com/repos/Praveenrajmani/minio/contributors","subscribers_url":"https://api.github.com/repos/Praveenrajmani/minio/subscribers","subscription_url":"https://api.github.com/repos/Praveenrajmani/minio/subscription","commits_url":"https://api.github.com/repos/Praveenrajmani/minio/commits{/sha}","git_commits_url":"https://api.github.com/repos/Praveenrajmani/minio/git/commits{/sha}","comments_url":"https://api.github.com/repos/Praveenrajmani/minio/comments{/number}","issue_comment_url":"https://api.github.com/repos/Praveenrajmani/minio/issues/comments{/number}","contents_url":"https://api.github.com/repos/Praveenrajmani/minio/contents/{+path}","compare_url":"https://api.github.com/repos/Praveenrajmani/minio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Praveenrajmani/minio/merges","archive_url":"https://api.github.com/repos/Praveenrajmani/minio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Praveenrajmani/minio/downloads","issues_url":"https://api.github.com/repos/Praveenrajmani/minio/issues{/number}","pulls_url":"https://api.github.com/repos/Praveenrajmani/minio/pulls{/number}","milestones_url":"https://api.github.com/repos/Praveenrajmani/minio/milestones{/number}","notifications_url":"https://api.github.com/repos/Praveenrajmani/minio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Praveenrajmani/minio/labels{/name}","releases_url":"https://api.github.com/repos/Praveenrajmani/minio/releases{/id}","deployments_url":"https://api.github.com/repos/Praveenrajmani/minio/deployments","created_at":"2018-05-03T05:40:17Z","updated_at":"2018-06-08T07:30:33Z","pushed_at":"2018-08-10T16:22:07Z","git_url":"git://github.com/Praveenrajmani/minio.git","ssh_url":"git@github.com:Praveenrajmani/minio.git","clone_url":"https://github.com/Praveenrajmani/minio.git","svn_url":"https://github.com/Praveenrajmani/minio","homepage":"https://minio.io/downloads.html#download-server","size":39537,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"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":"minio:master","ref":"master","sha":"64f2c6181312a951905533a04820f4817aa0441b","user":{"login":"minio","id":695951,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5NTk1MQ==","avatar_url":"https://avatars3.githubusercontent.com/u/695951?v=4","gravatar_id":"","url":"https://api.github.com/users/minio","html_url":"https://github.com/minio","followers_url":"https://api.github.com/users/minio/followers","following_url":"https://api.github.com/users/minio/following{/other_user}","gists_url":"https://api.github.com/users/minio/gists{/gist_id}","starred_url":"https://api.github.com/users/minio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minio/subscriptions","organizations_url":"https://api.github.com/users/minio/orgs","repos_url":"https://api.github.com/users/minio/repos","events_url":"https://api.github.com/users/minio/events{/privacy}","received_events_url":"https://api.github.com/users/minio/received_events","type":"Organization","site_admin":false},"repo":{"id":29261473,"node_id":"MDEwOlJlcG9zaXRvcnkyOTI2MTQ3Mw==","name":"minio","full_name":"minio/minio","owner":{"login":"minio","id":695951,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5NTk1MQ==","avatar_url":"https://avatars3.githubusercontent.com/u/695951?v=4","gravatar_id":"","url":"https://api.github.com/users/minio","html_url":"https://github.com/minio","followers_url":"https://api.github.com/users/minio/followers","following_url":"https://api.github.com/users/minio/following{/other_user}","gists_url":"https://api.github.com/users/minio/gists{/gist_id}","starred_url":"https://api.github.com/users/minio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minio/subscriptions","organizations_url":"https://api.github.com/users/minio/orgs","repos_url":"https://api.github.com/users/minio/repos","events_url":"https://api.github.com/users/minio/events{/privacy}","received_events_url":"https://api.github.com/users/minio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/minio/minio","description":"Minio is an open source object storage server compatible with Amazon S3 APIs","fork":false,"url":"https://api.github.com/repos/minio/minio","forks_url":"https://api.github.com/repos/minio/minio/forks","keys_url":"https://api.github.com/repos/minio/minio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/minio/minio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/minio/minio/teams","hooks_url":"https://api.github.com/repos/minio/minio/hooks","issue_events_url":"https://api.github.com/repos/minio/minio/issues/events{/number}","events_url":"https://api.github.com/repos/minio/minio/events","assignees_url":"https://api.github.com/repos/minio/minio/assignees{/user}","branches_url":"https://api.github.com/repos/minio/minio/branches{/branch}","tags_url":"https://api.github.com/repos/minio/minio/tags","blobs_url":"https://api.github.com/repos/minio/minio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/minio/minio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/minio/minio/git/refs{/sha}","trees_url":"https://api.github.com/repos/minio/minio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/minio/minio/statuses/{sha}","languages_url":"https://api.github.com/repos/minio/minio/languages","stargazers_url":"https://api.github.com/repos/minio/minio/stargazers","contributors_url":"https://api.github.com/repos/minio/minio/contributors","subscribers_url":"https://api.github.com/repos/minio/minio/subscribers","subscription_url":"https://api.github.com/repos/minio/minio/subscription","commits_url":"https://api.github.com/repos/minio/minio/commits{/sha}","git_commits_url":"https://api.github.com/repos/minio/minio/git/commits{/sha}","comments_url":"https://api.github.com/repos/minio/minio/comments{/number}","issue_comment_url":"https://api.github.com/repos/minio/minio/issues/comments{/number}","contents_url":"https://api.github.com/repos/minio/minio/contents/{+path}","compare_url":"https://api.github.com/repos/minio/minio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/minio/minio/merges","archive_url":"https://api.github.com/repos/minio/minio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/minio/minio/downloads","issues_url":"https://api.github.com/repos/minio/minio/issues{/number}","pulls_url":"https://api.github.com/repos/minio/minio/pulls{/number}","milestones_url":"https://api.github.com/repos/minio/minio/milestones{/number}","notifications_url":"https://api.github.com/repos/minio/minio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/minio/minio/labels{/name}","releases_url":"https://api.github.com/repos/minio/minio/releases{/id}","deployments_url":"https://api.github.com/repos/minio/minio/deployments","created_at":"2015-01-14T19:23:58Z","updated_at":"2018-08-12T19:01:03Z","pushed_at":"2018-08-12T12:28:28Z","git_url":"git://github.com/minio/minio.git","ssh_url":"git@github.com:minio/minio.git","clone_url":"https://github.com/minio/minio.git","svn_url":"https://github.com/minio/minio","homepage":"https://minio.io/downloads.html#download-server","size":39606,"stargazers_count":12433,"watchers_count":12433,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1097,"mirror_url":null,"archived":false,"open_issues_count":144,"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":1097,"open_issues":144,"watchers":12433,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/minio/minio/pulls/6079"},"html":{"href":"https://github.com/minio/minio/pull/6079"},"issue":{"href":"https://api.github.com/repos/minio/minio/issues/6079"},"comments":{"href":"https://api.github.com/repos/minio/minio/issues/6079/comments"},"review_comments":{"href":"https://api.github.com/repos/minio/minio/pulls/6079/comments"},"review_comment":{"href":"https://api.github.com/repos/minio/minio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/minio/minio/pulls/6079/commits"},"statuses":{"href":"https://api.github.com/repos/minio/minio/statuses/b6f720b56d4e0f02a72772012465bb72cd04026a"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"aead"}}