Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pbm/storage/mio/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,9 @@ func (m *Minio) Save(name string, data io.Reader, options ...storage.Option) err
}

putOpts := minio.PutObjectOptions{
PartSize: uint64(partSize),
NumThreads: uint(max(runtime.NumCPU()/2, 1)),
PartSize: uint64(partSize),
NumThreads: uint(max(runtime.NumCPU()/2, 1)),
ConcurrentStreamParts: true,
}
_, err := m.cl.PutObject(
context.Background(),
Expand Down
20 changes: 17 additions & 3 deletions pbm/storage/mio/minio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ go test ./pbm/storage/mio -bench=BenchmarkMinioPutObject -run=^$ -v \
-part-size=100
*/
func BenchmarkMinioPutObject(b *testing.B) {
var uploadTimes []time.Duration
numThreds := uint(max(runtime.GOMAXPROCS(0), 1))
fsize := *fileSize * 1024 * 1024
pSize := *partSize * 1024 * 1024
Expand Down Expand Up @@ -306,14 +307,15 @@ func BenchmarkMinioPutObject(b *testing.B) {
r := io.LimitReader(infR, fsize)

fname := time.Now().Format("2006-01-02T15:04:05")
b.Logf("uploading file: %s ....", fname)

putOpts := minio.PutObjectOptions{
PartSize: uint64(pSize),
NumThreads: numThreds,
PartSize: uint64(pSize),
NumThreads: numThreds,
ConcurrentStreamParts: true,
}

b.StartTimer()
startTime := time.Now()
_, err = mc.PutObject(
context.Background(),
bucket,
Expand All @@ -322,10 +324,22 @@ func BenchmarkMinioPutObject(b *testing.B) {
-1,
putOpts,
)
uploadDuration := time.Since(startTime)
uploadTimes = append(uploadTimes, uploadDuration)
b.Logf("uploading file: %s, completed in: %v", fname, uploadDuration)
if err != nil {
b.Fatalf("put object: %v", err)
}
}

if len(uploadTimes) > 0 {
var totalDuration time.Duration
for _, duration := range uploadTimes {
totalDuration += duration
}
averageTime := totalDuration / time.Duration(len(uploadTimes))
b.Logf("average upload time: %v", averageTime)
}
}

// BenchmarkMinioStorageSave measures the performance of uploading file on the
Expand Down
15 changes: 14 additions & 1 deletion pbm/storage/s3/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
if opts.Region != "" {
t.Error("Start value is not ''")
}
opts.Cast()

Check failure on line 178 in pbm/storage/s3/s3_test.go

View workflow job for this annotation

GitHub Actions / runner / golangci-lint

Error return value of `opts.Cast` is not checked (errcheck)

if opts.Region != "us-east-1" {
t.Error("Default value should be set on Cast")
Expand Down Expand Up @@ -264,6 +264,7 @@
-part-size=100
*/
func BenchmarkS3Upload(b *testing.B) {
var uploadTimes []time.Duration
numThreds := max(runtime.GOMAXPROCS(0), 1)
fsize := *fileSize * 1024 * 1024
pSize := *partSize * 1024 * 1024
Expand Down Expand Up @@ -298,7 +299,6 @@
r := io.LimitReader(infR, fsize)

fname := time.Now().Format("2006-01-02T15:04:05")
b.Logf("uploading file: %s ....", fname)

putInput := &s3.PutObjectInput{
Bucket: aws.String(bucket),
Expand All @@ -308,15 +308,28 @@
}

b.StartTimer()
startTime := time.Now()
_, err := manager.NewUploader(s3Client, func(u *manager.Uploader) {
u.PartSize = pSize
u.LeavePartsOnError = true
u.Concurrency = numThreds
}).Upload(context.Background(), putInput)
uploadDuration := time.Since(startTime)
uploadTimes = append(uploadTimes, uploadDuration)
b.Logf("uploading file: %s, completed in: %v", fname, uploadDuration)
if err != nil {
b.Fatalf("put object: %v", err)
}
}

if len(uploadTimes) > 0 {
var totalDuration time.Duration
for _, duration := range uploadTimes {
totalDuration += duration
}
averageTime := totalDuration / time.Duration(len(uploadTimes))
b.Logf("average upload time: %v", averageTime)
}
}

// BenchmarkS3StorageSave measures the performance of uploading file on the
Expand Down
Loading