Skip to content

Add methods for writing blob content directly from an array #768

@mrotteveel

Description

@mrotteveel

Similar to #766, performance of writes of blob content could be improved (especially for the pure Java implementation) by writing the segments directly from the array to the network stream (or the buffer used by JNA), skipping intermediate buffers. This would especially be worth it for byte arrays larger than the blobBufferSize, because right now large byte arrays will be copied over in blobBufferSize lengths, and writes with different offset or length not equal to the array size will be copied too as (max) blobBufferSize lengths, while writing from the source array directly into the network stream would allow us to write with the maximum segment size.

This will probably even be beneficial for writes larger than 50% of the blob buffer size under the assumption that multiple writes with that size will happen right after each other, because in the existing implementation, two writes of 50% + 1 will

  1. First write with size > blobBufferSize / 2 and size < blobBufferSize will copy into the buffer of the blob output stream
  2. Second write with size > blobBufferSize / 2 and size < blobBufferSize will flush that buffer, and then write itself (possibly with additional copying)

If the first write had directly gone to the network stream, we could have skipped the overhead of copying to the buffer (and then from the buffer to the network).

We might also be able to coalesce the buffer flush and a subsequent write into a single segment, but that might raise the complexity too much.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions