From 42f18815807cc0544692975702312b9b9799ed5b Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Wed, 5 Jul 2023 15:35:00 +0300 Subject: [PATCH] [#79] object put: Add chunk size parameter Signed-off-by: Dmitrii Stepanov --- internal/native/client.go | 11 +++++++---- scenarios/grpc.js | 3 ++- scenarios/grpc_car.js | 3 ++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/internal/native/client.go b/internal/native/client.go index 45aaac9..8145444 100644 --- a/internal/native/client.go +++ b/internal/native/client.go @@ -89,7 +89,7 @@ func (c *Client) SetBufferSize(size int) { } } -func (c *Client) Put(containerID string, headers map[string]string, payload goja.ArrayBuffer) PutResponse { +func (c *Client) Put(containerID string, headers map[string]string, payload goja.ArrayBuffer, chunkSize int) PutResponse { cliContainerID := parseContainerID(containerID) tok := c.tok @@ -116,7 +116,7 @@ func (c *Client) Put(containerID string, headers map[string]string, payload goja o.SetOwnerID(&owner) o.SetAttributes(attrs...) - resp, err := put(c.vu, c.bufsize, c.cli, &tok, &o, payload.Bytes()) + resp, err := put(c.vu, c.bufsize, c.cli, &tok, &o, payload.Bytes(), chunkSize) if err != nil { return PutResponse{Success: false, Error: err.Error()} } @@ -413,7 +413,7 @@ func (p PreparedObject) Put(headers map[string]string) PutResponse { return PutResponse{Success: false, Error: err.Error()} } - _, err = put(p.vu, p.bufsize, p.cli, nil, &obj, p.payload) + _, err = put(p.vu, p.bufsize, p.cli, nil, &obj, p.payload, 0) if err != nil { return PutResponse{Success: false, Error: err.Error()} } @@ -422,7 +422,7 @@ func (p PreparedObject) Put(headers map[string]string) PutResponse { } func put(vu modules.VU, bufSize int, cli *client.Client, tok *session.Object, - hdr *object.Object, payload []byte) (*client.ResObjectPut, error) { + hdr *object.Object, payload []byte, chunkSize int) (*client.ResObjectPut, error) { buf := make([]byte, bufSize) rdr := bytes.NewReader(payload) sz := rdr.Size() @@ -434,6 +434,9 @@ func put(vu modules.VU, bufSize int, cli *client.Client, tok *session.Object, if tok != nil { prm.WithinSession(*tok) } + if chunkSize > 0 { + prm.SetGRPCPayloadChunkLen(chunkSize) + } objectWriter, err := cli.ObjectPutInit(vu.Context(), prm) if err != nil { diff --git a/scenarios/grpc.js b/scenarios/grpc.js index 8b89443..cfd6790 100644 --- a/scenarios/grpc.js +++ b/scenarios/grpc.js @@ -52,6 +52,7 @@ const generator = datagen.generator(1024 * parseInt(__ENV.WRITE_OBJ_SIZE), __ENV const scenarios = {}; const write_vu_count = parseInt(__ENV.WRITERS || '0'); +const write_grpc_chunk_size = 1024 * parseInt(__ENV.GRPC_CHUNK_SIZE || '0') if (write_vu_count > 0) { scenarios.write = { executor: 'constant-vus', @@ -129,7 +130,7 @@ export function obj_write() { const container = container_list[Math.floor(Math.random() * container_list.length)]; const { payload, hash } = generator.genPayload(registry_enabled); - const resp = grpc_client.put(container, headers, payload); + const resp = grpc_client.put(container, headers, payload, write_grpc_chunk_size); if (!resp.success) { log.withField("cid", container).error(resp.error); return; diff --git a/scenarios/grpc_car.js b/scenarios/grpc_car.js index 59cc96c..4fe8589 100644 --- a/scenarios/grpc_car.js +++ b/scenarios/grpc_car.js @@ -55,6 +55,7 @@ const time_unit = __ENV.TIME_UNIT || '1s'; const pre_alloc_write_vus = parseInt(__ENV.PRE_ALLOC_WRITERS || '0'); const max_write_vus = parseInt(__ENV.MAX_WRITERS || pre_alloc_write_vus); const write_rate = parseInt(__ENV.WRITE_RATE || '0'); +const write_grpc_chunk_size = 1024 * parseInt(__ENV.GRPC_CHUNK_SIZE || '0') if (write_rate > 0) { scenarios.write = { executor: 'constant-arrival-rate', @@ -154,7 +155,7 @@ export function obj_write() { const container = container_list[Math.floor(Math.random() * container_list.length)]; const { payload, hash } = generator.genPayload(registry_enabled); - const resp = grpc_client.put(container, headers, payload); + const resp = grpc_client.put(container, headers, payload, write_grpc_chunk_size); if (!resp.success) { log.withField("cid", container).error(resp.error); return;