Add validation and optimise objects.BulkDelete#2597
Add validation and optimise objects.BulkDelete#2597mandre merged 3 commits intogophercloud:masterfrom
Conversation
* Validate that the container name does not contain `/` * Validate that all provided objects are non-empty
506b894 to
6b6fadf
Compare
|
@pierreprinetti I wonder whether it will work with the new versioning system |
6b6fadf to
80825f5
Compare
Use `bytes.Buffer` instead of repeatedly copying strings to compose the request body for `objects.BulkDelete`. This commit does not hook the function to the API; it provides the benchmark tests. Benchmark with: ```shell cd openstack/objectstorage/v1/objects/testing go test -bench=. ``` Locally I get a marginal gain when bulk-deleting only a few objects, and good gains (to around 3/4 of the time per execution) with large batches: ```plaintext goos: linux goarch: amd64 pkg: github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects/testing cpu: Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz BenchmarkBulkDelete-8 246 4536244 ns/op BenchmarkBulkDeleteFewerObjects-8 11943 97338 ns/op BenchmarkBulkDeleteWithBuffer-8 303 3463102 ns/op BenchmarkBulkDeleteWithBufferFewerObjects-8 11587 92153 ns/op PASS ok github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects/testing 19.943s ```
80825f5 to
ee053f0
Compare
I wouldn't know, but this new function is expected to replace the old one with the same exact behaviour. Plus the validations. Do you think the validations would impact versioned files? |
|
@pierreprinetti I don't know. Just thinking out loud. It may happen that this function consumers may face 409 on objects or container deletion :\ |
| @@ -576,15 +576,25 @@ func CreateTempURL(c *gophercloud.ServiceClient, containerName, objectName strin | |||
|
|
|||
| // BulkDelete is a function that bulk deletes objects. | |||
There was a problem hiding this comment.
Unrelated to this change, but I wonder if we should mention the (configurable) limit of 10,000 objects per request?
There was a problem hiding this comment.
I wasn't able to find a reference to a limit in the API docs. Did you find that in the code of Swift/Ceph?
There was a problem hiding this comment.
There was a problem hiding this comment.
wonderful, thank you @stephenfin @EmilienM. I have added that information in the function docs. PTAL
This commit replaces the old BulkDelete function with the new one, which has been measured to be faster.
ee053f0 to
58b1c67
Compare
This PR makes the following changes to
objects.BulkDelete:/;Note that the function mentions urlencoding in a comment, but there is no urlencoding. I have removed the comment and kept the behaviour. We might want to consider add urlencoding in a follow-up.
WRT the optimisation:
Use
bytes.Bufferinstead of repeatedly copying strings to compose the request body forobjects.BulkDelete.This PR adds, and in a separate commit, removes the benchmark tests. To execute the benchmark:
Locally I get a marginal gain when bulk-deleting only a few objects, and
good gains (to around 3/4 of the time per execution) with large batches: