mirror of
https://github.com/apache/jclouds.git
synced 2025-02-07 10:39:03 +00:00
1c57d07f70
This change improves the performance of writing to sockets with the default Java URL connection HTTP client, by enlarging the buffer used for socket writes from an implicit hard-coded 4KB / 8KB buffer to a configurable 32KB buffer. The buffer size is now controlled by the following property with the following default value: jclouds.output-socket-buffer-size: 32768 The implementation is based on a variant of ByteStreams.copy (written as ByteStreams2.copy) which accepts the buffer size as an argument, unlike the original Guava code that uses a hard-coded size. The change was done directly within the loop that copies the input stream to the output stream, and not by wrapping a BufferedOutputStream around the existing output stream, in order to avoid copying the payload twice. On some platforms this change can improve both the putBlob throughput and the total CPU consumption.