Repository navigation
[core] Increase default BLOB copy buffer to 256 KiB - #1563
Conversation
leaves12138
left a comment
There was a problem hiding this comment.
Reviewed base main at head 340f845. Full file list (11 files): Python binding video writer (README, data.pyi, video.rs, tests), core BLOB writer (writer.rs, writer_consumer_tests.rs), io/file_io.rs, spec/core_options.rs, table/internal.rs (PackedVideoWriter), table/managed_blob_writer.rs, and tests/blob_update_test.rs.
Core change notice: this changes the shared default blob.copy-buffer-size (4 KiB to 256 KiB) for core, managed PK BLOB packs, and the standalone Python video writer, and extends the public FileWrite trait with write_slice (default implementation copies, so external implementors stay compatible). The local-file write path and BLOB output selection are generic IO semantics affecting all writers, not only BLOB.
Analysis:
- Borrowed slices: the default
write_slicecopies intoBytes, preserving behavior for buffering outputs;LocalFileWriteroverrides it withwrite_allon the tokio BufWriter, andCacheInvalidatingWriterdelegates, so cache invalidation is preserved. The consumer test asserts payload chunk writes borrow the exact Arrow buffer addresses (sliced array included) and CRC bytes remain correct. blob_writer(require_flush)replacesflushable_writer: non-local outputs without a consumer keep the ordinary bulk path; local outputs use an 8 KiB BufWriter for record headers/trailers on ordinary writes and 8 MiB when a consumer needs partial-chunk draining. Both local variants now reject directory paths and root/prefix escapes before opening the file (previously the non-flush local path bypassedLocalFileWritervalidation entirely — this closes that gap rather than adding a restriction).- Overflow accounting:
checked_write_endis computed before hashing/writing in both the owned and borrowed paths, keepingbytes_writtenconsistent on failure. - Managed writer fix:
uncommitted_paths.pushnow happens before the writer is constructed, so a failedBlobFormatWriter::newstill leaves the created file tracked for cleanup — a real leak fix. - Default sync:
CoreOptions::DEFAULT_BLOB_COPY_BUFFER_SIZEis shared by the BLOB writer, managed packs, andPackedVideoWriter; the pyo3 signature and.pyiagree on 262144; the blob-update test readers now assert against the configured default instead of hardcoded 4096.
No findings. Coverage includes default/override chunk sizes (Rust + Python), borrowed-address assertions, local flush with and without a consumer, directory-path rejection, and the integration suite.
CI note: 15 jobs pending on this head; the author ran 107 Rust tests, the 31 blob-update integration tests, 15 Python video tests against a local wheel, and cargo fmt locally. Approving without waiting for CI. Companion Java/Python change: apache/paimon#11535.
LGTM.
Purpose
Increase the default
blob.copy-buffer-sizefrom 4 KiB to 256 KiB to reduce per-chunk overhead when writing large BLOB payloads.Brief change log
Use the same default in core options, standalone BLOB format writers, primary-key managed BLOB pack writers, and the standalone Python
VideoFormatWriter. Explicit buffer sizes still take precedence.Pass inline BLOB chunks as borrowed slices. An open built-in local file can consume those slices directly. Outputs that buffer writes retain owned chunks and copy borrowed slices only when the data must outlive the call.
Ordinary local BLOB writes and primary-key managed packs stage up to 8 MiB before opening the destination. A nonempty write beyond that capacity, a flush with pending data, or close opens the file. This preserves the file descriptor behavior of OpenDAL's chunked writer across sparse partitions. After opening, ordinary local files use a 256 KiB output buffer to batch small records and their framing. Local writers with a BLOB consumer confirm the destination can be opened before delivering descriptors. Direct local writes preserve OpenDAL's file path validation.
Check the BLOB update test readers' request sizes against the configured default. The old 4 KiB assertion caused six failures in the Linux unit job after the default increased.
Tests
vortexfeature across BLOB updates, dedicated and partitioned BLOBs, collections, managed packs, and video. These include all 31blob_update_testcases.cargo fmt --check --allpassed.cargo clippy --locked -p paimon --lib --features vortex -- -D warningspassed.API and Format
This updates the default of the existing
blob.copy-buffer-sizetable option and addsFileWrite::write_slicewith a default implementation.Documentation
The companion Java and Python PR updates the generated configuration reference.