@@ -52,13 +52,18 @@ function putObjectImpl(x::AbstractStore, key::String, in::RequestBodyType;
52
52
batchSize:: Int = defaultBatchSize (),
53
53
allowMultipart:: Bool = true ,
54
54
zlibng:: Bool = false ,
55
- compress:: Bool = false , credentials= nothing , kw... )
55
+ compress:: Bool = false , credentials= nothing ,
56
+ lograte:: Bool = false , kw... )
56
57
58
+ start_time = time ()
57
59
N = nbytes (in)
60
+ wbytes = Threads. Atomic {Int} (0 )
58
61
if N <= multipartThreshold || ! allowMultipart
59
62
body = prepBody (in, compress, zlibng)
60
63
resp = putObject (x, key, body; credentials, kw... )
61
- return Object (x, credentials, key, N, etag (HTTP. header (resp, " ETag" )))
64
+ wbytes[] = get (resp. request. context, :nbytes_written , 0 )
65
+ obj = Object (x, credentials, key, N, etag (HTTP. header (resp, " ETag" )))
66
+ @goto done
62
67
end
63
68
# multipart upload
64
69
uploadState = startMultipartUpload (x, key; credentials, kw... )
@@ -76,15 +81,13 @@ function putObjectImpl(x::AbstractStore, key::String, in::RequestBodyType;
76
81
eof (body) && break
77
82
n = (j - 1 ) * batchSize + i
78
83
part = _read (body, partSize)
79
- let n= n, part= part
80
- Threads. @spawn begin
81
- eTag = uploadPart (x, url, part, n, uploadState; credentials, kw... )
82
- let eTag= eTag
83
- # we synchronize the eTags here because the order matters
84
- # for the final call to completeMultipartUpload
85
- put! (() -> push! (eTags, eTag), sync, n)
86
- end
87
- end
84
+ Threads. @spawn begin
85
+ _n = $ n
86
+ parteTag, wb = uploadPart (x, url, $ part, _n, uploadState; credentials, kw... )
87
+ Threads. atomic_add! (wbytes, wb)
88
+ # we synchronize the eTags here because the order matters
89
+ # for the final call to completeMultipartUpload
90
+ put! (() -> push! (eTags, parteTag), sync, _n)
88
91
end
89
92
end
90
93
eof (body) && break
@@ -97,5 +100,11 @@ function putObjectImpl(x::AbstractStore, key::String, in::RequestBodyType;
97
100
close (body)
98
101
end
99
102
eTag = completeMultipartUpload (x, url, eTags, uploadState; credentials, kw... )
100
- return Object (x, credentials, key, N, eTag)
103
+ obj = Object (x, credentials, key, N, eTag)
104
+ @label done
105
+ end_time = time ()
106
+ bytes = wbytes[]
107
+ gbits_per_second = bytes == 0 ? 0 : (((8 * bytes) / 1e9 ) / (end_time - start_time))
108
+ lograte && @info " CloudStore.put complete with bandwidth: $(gbits_per_second) Gbps"
109
+ return obj
101
110
end
0 commit comments