Skip to content

[core] Increase default BLOB copy buffer to 256 KiB - #1563

Merged
JingsongLi merged 6 commits into
apache:mainfrom
JingsongLi:codex/blob-copy-buffer-256k
Nov 30, 2026
Merged

JingsongLi merged 6 commits into
apache:mainfrom
JingsongLi:codex/blob-copy-buffer-256k

Conversation

@JingsongLi

@JingsongLi JingsongLi commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Increase the default blob.copy-buffer-size from 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

  • 153 Rust unit tests passed across file I/O, BLOB and video formats, BLOB consumers, and managed BLOB packs.
  • 61 Rust integration tests passed with the vortex feature across BLOB updates, dedicated and partitioned BLOBs, collections, managed packs, and video. These include all 31 blob_update_test cases.
  • A local probe with a 64-descriptor limit completed 96 small files with the deferred writer. The eager implementation exhausted descriptors before the grouped closes.
  • A macOS local writer probe wrote about 64 MiB of 8 KiB inline records at a fixed 256 KiB copy setting. Raising the post-open output buffer from 8 KiB to 256 KiB reduced median write-and-close time from 221 ms to 52 ms. Output checksums matched.
  • All 15 Python video writer tests passed against a locally built native wheel, including chunk sizes for the default and an explicit override.
  • cargo fmt --check --all passed.
  • cargo clippy --locked -p paimon --lib --features vortex -- -D warnings passed.

API and Format

This updates the default of the existing blob.copy-buffer-size table option and adds FileWrite::write_slice with a default implementation.

Documentation

The companion Java and Python PR updates the generated configuration reference.

@leaves12138 leaves12138 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_slice copies into Bytes, preserving behavior for buffering outputs; LocalFileWriter overrides it with write_all on the tokio BufWriter, and CacheInvalidatingWriter delegates, 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) replaces flushable_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 bypassed LocalFileWriter validation entirely — this closes that gap rather than adding a restriction).
  • Overflow accounting: checked_write_end is computed before hashing/writing in both the owned and borrowed paths, keeping bytes_written consistent on failure.
  • Managed writer fix: uncommitted_paths.push now happens before the writer is constructed, so a failed BlobFormatWriter::new still leaves the created file tracked for cleanup — a real leak fix.
  • Default sync: CoreOptions::DEFAULT_BLOB_COPY_BUFFER_SIZE is shared by the BLOB writer, managed packs, and PackedVideoWriter; the pyo3 signature and .pyi agree 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.

@JingsongLi
JingsongLi merged commit e4b84b4 into apache:main Nov 30, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants