Skip to content

Commit

Permalink
Performance drop when object size is large
Browse files Browse the repository at this point in the history
cherry-pick from https://github.com/mulbc/gosbench/pull/10/files

Signed-off-by: Liang Zheng <zhengliang0901@gmail.com>
  • Loading branch information
microyahoo authored and mulbc committed Dec 19, 2023
1 parent 80d7bc8 commit fb921ec
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 9 deletions.
7 changes: 7 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ Note: Due to the constant distribution, we will only consider the `_min` values.

This will cause each workers to search for pre-existing files in the buckets `myBucket-0` and `myBucket-1` and read 10 objects from these buckets. If there are less than 10 objects in any of these buckets, some objects will be read multiple times. The object size given in your config will be ignored when reading pre-existing files.

## Cosbench vs Gosbench benchmark comparision
When a new tool is presented, it’s essential to compare it to existing tools for accuracy. For this reason, we ran a comparision between Cosbench and Gosbench. Both benchmarks were tasked to do a 100% write test and 100% read test on 4KB, 16KB, 256KB, 1MB, 4MB objects for 60 seconds each. The tests were to run on one RGW using S3 protocol in ceph storage clusteri, also run in the test configuration in parallel. Figure below show writing and reading, respectively. From these charts, it’s apparent that the performance metrics for all objects are similar for both tools.

![Latency](examples/Latency.png)

![Bandwidth](examples/Bandwidth.png)

## Contributing

* Be aware that this repo uses pre-commit hooks - install them via `pre-commit install`
Expand Down
Binary file added examples/Bandwidth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/Latency.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"math/rand"
"net"
"os"
"runtime"
"sync"
"time"

Expand All @@ -21,6 +22,7 @@ var prometheusPort int
var debug, trace bool

func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
log.SetFormatter(&log.TextFormatter{
FullTimestamp: true,
})
Expand Down
22 changes: 14 additions & 8 deletions worker/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,23 @@ func listObjects(service *s3.S3, prefix string, bucket string) (*s3.ListObjectsV
return result, err
}

func getObject(service *s3.S3, objectName string, bucket string) error {
// Create a downloader with the session and custom options
downloader := s3manager.NewDownloaderWithClient(service)
buf := aws.NewWriteAtBuffer([]byte{})
_, err := downloader.DownloadWithContext(ctx, buf, &s3.GetObjectInput{
func getObject(service *s3.S3, objectName string, bucket string, objectSize uint64) error {
// Remove the allocation of buffer
result, err := svc.GetObjectWithContext(ctx, &s3.GetObjectInput{
Bucket: &bucket,
Key: &objectName,
}, func(d *s3manager.Downloader) {
d.PartSize = 64 * 1024 * 1024 // 64MB parts
})
return err
if err != nil {
return err
}
numBytes, err := io.Copy(io.Discard, result.Body)
if err != nil {
return err
}
if numBytes != int64(objectSize) {
return fmt.Errorf("Expected object length %d is not matched to actual object length %d", objectSize, numBytes)
}
return nil
}

func deleteObject(service *s3.S3, objectName string, bucket string) error {
Expand Down
2 changes: 1 addition & 1 deletion worker/workItems.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (op *Stopper) Prepare() error {
func (op *ReadOperation) Do() error {
log.WithField("bucket", op.Bucket).WithField("object", op.ObjectName).WithField("Preexisting?", op.WorksOnPreexistingObject).Debug("Doing ReadOperation")
start := time.Now()
err := getObject(svc, op.ObjectName, op.Bucket)
err := getObject(svc, op.ObjectName, op.Bucket, op.ObjectSize)
duration := time.Since(start)
promLatency.WithLabelValues(op.TestName, "GET").Observe(float64(duration.Milliseconds()))
if err != nil {
Expand Down

0 comments on commit fb921ec

Please sign in to comment.