Repository navigation
[core][python] Increase default BLOB copy buffer to 256 KiB - #11535
Conversation
leaves12138
left a comment
There was a problem hiding this comment.
Reviewed base master at head 08c2f64. Full file list (13 files): generated config docs, paimon-api/CoreOptions.java, paimon-format blob writers (AbstractBlobElementWriter, BlobFormatWriter), PyPaimon (core_options.py, native_commit.py, blob_format_writer.py, video_format_writer.py, table/row/blob.py), and four test files.
Core change notice: this changes the default of the public table option blob.copy-buffer-size (4 KiB to 256 KiB) across Java, PyPaimon, and the native runtime forwarding, plus the generic BLOB copy path in paimon-format shared by append BLOB writes, primary-key BLOB writes, and video packing. All engines writing BLOB payloads are affected; explicit settings still win.
Analysis:
- Java lazy buffer: allocation happens on first need, bounded by min(payload length, cap) for known-length refs; growth doubles up to the cap and covers the request, so small blobs never pay 256 KiB and construction-only writers allocate nothing (probe tests assert buffer identity/size across a sequence of lengths, including the unknown-length fallback reusing the grown buffer).
- Inline
BlobDatafast path is exact-class only, so subclasses overridingnewInputStreamstill go through the stream path (dedicated subclass test); chunked writes use the original array with correct offset/length for both CRC and output, verified by an offset-recording wrapper. - The reworked
writeBlobDatapreserves the previous semantics: reused bounded streams are not closed and are discarded on failure; owned streams are closed via try-with-resources on all paths; metrics accounting reads/writes the same byte counts, with the inline path feeding chunks without reads. Zero-length refs short-circuit before allocation. - PyPaimon:
OffsetInputStream._read_chunkstracks remaining length, adjusts requests after short reads, and queriestellonce per copy (request-sequence test with a 2-byte short-read stream); the fast path is exact-type gated like Java.native_commitusessetdefault, so explicit user/table values are never overridden and older native runtimes receive the new default. - Default sync: CoreOptions,
BlobFormatWriter.DEFAULT_COPY_BUFFER_SIZE, PythonBUFFER_SIZE, and the generated docs all agree on 256 KiB; validation bounds are unchanged.
No findings. Test coverage is thorough on both sides (Java 126, Python 193 + 122 native per the description), including default/override chunk-size assertions against recording readers.
CI note: checks are still initializing on this head; the author ran the Java and Python suites locally with flake8 clean. Approving without waiting for CI. Companion Rust default change: apache/paimon-rust#1563.
LGTM.
Purpose
Increase the default
blob.copy-buffer-sizefrom 4 KiB to 256 KiB in Java and PyPaimon. PyPaimon forwards the default through its resolved write options so the released native runtime picks it up.In a single-writer Java 8 benchmark with 8 MiB BLOBs and local output, median throughput rose from 938 to 3,405 MiB/s with local input and from 249 to 317 MiB/s with loopback HTTP input.
Java now allocates its copy buffer on the first streamed payload that needs it. For known-length
BlobRefvalues, the first allocation is bounded by the payload length and configured cap. Growth doubles the capacity up to that cap, covers the requested size, and releases the previous scratch array before allocating its replacement. In an allocation probe with 1,024 references of increasing length, cumulative writer-thread allocation dropped from 124.85 MiB with exact growth to 0.70 MiB. InlineBlobDatauses the original array for chunked CRC updates and writes. A construction-only probe with 128 Java writers measured 32 MiB of copy buffers with eager 256 KiB allocation and 0 bytes with lazy allocation.PyPaimon tracks the remaining length while copying bounded BLOB and video references. The copy loop adjusts requests after short reads and queries the starting position once.
The companion Rust change is apache/paimon-rust#1563.
Tests
pypaimon-rust==0.5.0, including the 256 KiB default and a 3-byte explicit override.