IO::StreamSourceIOStream

module Stream

Nested

Definitions

BLOCK_SIZE = ENV.fetch("IO_STREAM_BLOCK_SIZE", 1024*256).to_i

The default block size for IO buffers. Defaults to 256KB (optimized for modern SSDs and networks).

MINIMUM_READ_SIZE = ENV.fetch("IO_STREAM_MINIMUM_READ_SIZE", BLOCK_SIZE).to_i

The minimum read size for efficient I/O operations. Defaults to the same as BLOCK_SIZE.

MAXIMUM_READ_SIZE = ENV.fetch("IO_STREAM_MAXIMUM_READ_SIZE", MINIMUM_READ_SIZE * 64).to_i

The maximum read size for a single read operation. This limit exists because:

  1. System calls like read() cannot handle requests larger than SSIZE_MAX
  2. Very large reads can cause memory pressure and poor interactive performance
  3. Most socket buffers and pipe capacities are much smaller anyway On 64-bit systems SSIZE_MAX is ~8.8 million MB, on 32-bit it's ~2GB. Our default of 16MB provides a good balance of throughput and responsiveness, and is page aligned. It is also a multiple of the minimum read size, so that we can read in chunks without exceeding the maximum.

MINIMUM_WRITE_SIZE = ENV.fetch("IO_STREAM_MINIMUM_WRITE_SIZE", BLOCK_SIZE).to_i

The minimum write size before flushing. Defaults to 64KB.