Skip to content

Commit a6ca46d

Browse files
committed
Added benchmark, Moved minio-deps to fork without race fix we don't need.
Fixes: #3917 Long term fix: #3967 Signed-off-by: Bartlomiej Plotka <[email protected]>
1 parent 1dce996 commit a6ca46d

File tree

6 files changed

+64
-10
lines changed

6 files changed

+64
-10
lines changed

docs/storage.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ config:
9292
trace:
9393
enable: false
9494
list_objects_version: ""
95-
part_size: 134217728
95+
part_size: 67108864
9696
sse_config:
9797
type: ""
9898
kms_key_id: ""

go.mod

+3
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ replace (
7676
github.com/bradfitz/gomemcache => github.com/themihai/gomemcache v0.0.0-20180902122335-24332e2d58ab
7777
// Update to v1.1.1 to make sure windows CI pass.
7878
github.com/elastic/go-sysinfo => github.com/elastic/go-sysinfo v1.1.1
79+
80+
// TODO: Remove this: https://github.com/thanos-io/thanos/issues/3967.
81+
github.com/minio/minio-go/v7 => github.com/bwplotka/minio-go/v7 v7.0.11-0.20210324165441-f9927e5255a6
7982
// Make sure Prometheus version is pinned as Prometheus semver does not include Go APIs.
8083
github.com/prometheus/prometheus => github.com/prometheus/prometheus v1.8.2-0.20210215121130-6f488061dfb4
8184
github.com/sercand/kuberesolver => github.com/sercand/kuberesolver v2.4.0+incompatible

go.sum

+2-4
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnweb
195195
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
196196
github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c=
197197
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
198+
github.com/bwplotka/minio-go/v7 v7.0.11-0.20210324165441-f9927e5255a6 h1:h9SZ0jmAKjtrZF6iZ77/jdXdHr+Usn29itI669SVRp4=
199+
github.com/bwplotka/minio-go/v7 v7.0.11-0.20210324165441-f9927e5255a6/go.mod h1:td4gW1ldOsj1PbSNS+WYK43j+P1XVhX/8W8awaYlBFo=
198200
github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34=
199201
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
200202
github.com/cenkalti/backoff v0.0.0-20181003080854-62661b46c409/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
@@ -900,10 +902,6 @@ github.com/minio/md5-simd v1.1.0 h1:QPfiOqlZH+Cj9teu0t9b1nTBfPbyTl16Of5MeuShdK4=
900902
github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw=
901903
github.com/minio/minio-go/v6 v6.0.44/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg=
902904
github.com/minio/minio-go/v6 v6.0.56/go.mod h1:KQMM+/44DSlSGSQWSfRrAZ12FVMmpWNuX37i2AX0jfI=
903-
github.com/minio/minio-go/v7 v7.0.2 h1:P/7wFd4KrRBHVo7AKdcqO+9ReoS+XpMjfRFoE5quH0E=
904-
github.com/minio/minio-go/v7 v7.0.2/go.mod h1:dJ80Mv2HeGkYLH1sqS/ksz07ON6csH3S6JUMSQ2zAns=
905-
github.com/minio/minio-go/v7 v7.0.10 h1:1oUKe4EOPUEhw2qnPQaPsJ0lmVTYLFu03SiItauXs94=
906-
github.com/minio/minio-go/v7 v7.0.10/go.mod h1:td4gW1ldOsj1PbSNS+WYK43j+P1XVhX/8W8awaYlBFo=
907905
github.com/minio/sha256-simd v0.1.1 h1:5QHSlgo3nt5yKOJrC7W8w7X+NFl8cMPZm96iu8kKUJU=
908906
github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
909907
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=

pkg/objstore/s3/s3.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ var DefaultConfig = Config{
6666
MaxIdleConnsPerHost: 100,
6767
MaxConnsPerHost: 0,
6868
},
69-
// Minimum file size after which an HTTP multipart request should be used to upload objects to storage.
70-
// Set to 128 MiB as in the minio client.
71-
PartSize: 1024 * 1024 * 128,
69+
PartSize: 1024 * 1024 * 64, // 64MB.
7270
}
7371

7472
// Config stores the configuration for s3 bucket.
@@ -85,6 +83,7 @@ type Config struct {
8583
TraceConfig TraceConfig `yaml:"trace"`
8684
ListObjectsVersion string `yaml:"list_objects_version"`
8785
// PartSize used for multipart upload. Only used if uploaded object size is known and larger than configured PartSize.
86+
// NOTE we need to make sure this number does not produce more parts than 10 000.
8887
PartSize uint64 `yaml:"part_size"`
8988
SSEConfig SSEConfig `yaml:"sse_config"`
9089
}
@@ -449,7 +448,6 @@ func (b *Bucket) Upload(ctx context.Context, name string, r io.Reader) error {
449448
size = -1
450449
}
451450

452-
// partSize cannot be larger than object size.
453451
partSize := b.partSize
454452
if size < int64(partSize) {
455453
partSize = 0

pkg/objstore/s3/s3_e2e_test.go

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Copyright (c) The Thanos Authors.
2+
// Licensed under the Apache License 2.0.
3+
4+
package s3_test
5+
6+
import (
7+
"bytes"
8+
"context"
9+
"strings"
10+
"testing"
11+
12+
"github.com/cortexproject/cortex/integration/e2e"
13+
e2edb "github.com/cortexproject/cortex/integration/e2e/db"
14+
"github.com/go-kit/kit/log"
15+
"github.com/thanos-io/thanos/pkg/objstore/s3"
16+
"github.com/thanos-io/thanos/test/e2e/e2ethanos"
17+
18+
"github.com/thanos-io/thanos/pkg/testutil"
19+
)
20+
21+
// Regression benchmark for https://github.com/thanos-io/thanos/issues/3917.
22+
func BenchmarkUpload(b *testing.B) {
23+
b.ReportAllocs()
24+
ctx := context.Background()
25+
26+
s, err := e2e.NewScenario("e2e_bench_mino_client")
27+
testutil.Ok(b, err)
28+
b.Cleanup(e2ethanos.CleanScenario(b, s))
29+
30+
const bucket = "test"
31+
m := e2edb.NewMinio(8080, bucket)
32+
testutil.Ok(b, s.StartAndWaitReady(m))
33+
34+
bkt, err := s3.NewBucketWithConfig(log.NewNopLogger(), s3.Config{
35+
Bucket: bucket,
36+
AccessKey: e2edb.MinioAccessKey,
37+
SecretKey: e2edb.MinioSecretKey,
38+
Endpoint: m.HTTPEndpoint(),
39+
Insecure: true,
40+
}, "test-feed")
41+
testutil.Ok(b, err)
42+
43+
buf := bytes.Buffer{}
44+
buf.Grow(1028 * 1028 * 100) // 100MB.
45+
word := "abcdefghij"
46+
for i := 0; i < buf.Cap()/len(word); i++ {
47+
_, _ = buf.WriteString(word)
48+
}
49+
str := buf.String()
50+
51+
b.ResetTimer()
52+
for i := 0; i < b.N; i++ {
53+
testutil.Ok(b, bkt.Upload(ctx, "test", strings.NewReader(str)))
54+
}
55+
}

test/e2e/e2ethanos/helpers.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"github.com/thanos-io/thanos/pkg/testutil"
1717
)
1818

19-
func CleanScenario(t *testing.T, s *e2e.Scenario) func() {
19+
func CleanScenario(t testing.TB, s *e2e.Scenario) func() {
2020
return func() {
2121
// Make sure Clean can properly delete everything.
2222
testutil.Ok(t, exec.Command("chmod", "-R", "777", s.SharedDir()).Run())

0 commit comments

Comments
 (0)