From 8f7750b1ce127adbc2f11f0a66b2e1af7f40b2db Mon Sep 17 00:00:00 2001 From: Junpei Kawamoto Date: Fri, 22 Jan 2021 17:10:38 -0500 Subject: [PATCH 1/2] Use SerialBlobUploader if P = 1 --- renter/renterutil/kv.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/renter/renterutil/kv.go b/renter/renterutil/kv.go index b4666f4..fa9f449 100644 --- a/renter/renterutil/kv.go +++ b/renter/renterutil/kv.go @@ -32,11 +32,20 @@ func (kv PseudoKV) Put(ctx context.Context, key []byte, r io.Reader) error { if err := kv.DB.AddBlob(b); err != nil { return err } - bu := ParallelBlobUploader{ - U: kv.Uploader, - M: kv.M, - N: kv.N, - P: kv.P, + var bu BlobUploader + if kv.P == 1 { + bu = SerialBlobUploader{ + U: kv.Uploader, + M: kv.M, + N: kv.N, + } + } else { + bu = ParallelBlobUploader{ + U: kv.Uploader, + M: kv.M, + N: kv.N, + P: kv.P, + } } return bu.UploadBlob(ctx, kv.DB, b, r) } From 12c5e496803c8008c21fabef07f92fbacd592443 Mon Sep 17 00:00:00 2001 From: Junpei Kawamoto Date: Fri, 22 Jan 2021 17:13:34 -0500 Subject: [PATCH 2/2] Use SerialBlobDownloader if P = 1 --- renter/renterutil/kv.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/renter/renterutil/kv.go b/renter/renterutil/kv.go index fa9f449..0132707 100644 --- a/renter/renterutil/kv.go +++ b/renter/renterutil/kv.go @@ -100,9 +100,16 @@ func (kv PseudoKV) GetRange(ctx context.Context, key []byte, w io.Writer, off, n if err != nil { return err } - bd := ParallelBlobDownloader{ - D: kv.Downloader, - P: kv.P, + var bd BlobDownloader + if kv.P == 1 { + bd = SerialBlobDownloader{ + D: kv.Downloader, + } + } else { + bd = ParallelBlobDownloader{ + D: kv.Downloader, + P: kv.P, + } } return bd.DownloadBlob(ctx, kv.DB, b, w, off, n) }