Repository navigation
sdk/python: write in 4 MiB chunks to avoid the native 1 GiB buffer limit - #7863
Merged
jiefenghuang merged 5 commits intoNov 19, 2026
Merged
Conversation
Signed-off-by: Xucheng Zhou <aden1350@outlook.com>
adenzhou1350
requested review from
CaitinChen and
jiefenghuang
as code owners
November 17, 2026 05:40
- Split writes into 4 MiB native calls instead of 1 GiB to bound libjfs buffer memory (1 GiB + 1 byte test: peak RSS 3.2G -> 2.4G). - If a later chunk fails, return the bytes already written instead of raising, matching short-write semantics. - Build the test payload in memory instead of via a temp file. - Drop the docs note and unrelated whitespace changes.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7863 +/- ##
===========================================
- Coverage 52.08% 21.67% -30.42%
===========================================
Files 34 33 -1
Lines 27825 27136 -689
===========================================
- Hits 14493 5881 -8612
- Misses 11539 20656 +9117
+ Partials 1793 599 -1194 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Raise EIO if jfs_pwrite makes no progress instead of looping forever, advance the position by the bytes already written when a chunk fails, and build the loop-invariant ctypes arguments once.
Replace the 1 GiB + 1 byte test with an 8 MiB + 1 byte write that spies on jfs_pwrite and checks every native call stays within 4 MiB, cutting the test from ~23s and >2 GiB RSS to about a second. Drop the toBuf comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A Python SDK
write()larger than 1 GiB aborts the process:libjfs.toBufviews the buffer as*[1<<30]byte, sojfs_pwritepanics withslice bounds out of rangeeven though its count is int32. Writes over 2 GiB also overflow thec_int32count.Change
_File.write()passes the buffer tojfs_pwritein 4 MiB chunks (same size asread()/readinto()), advancing the pointer without copying.OSError(no short write);lengthcovers the chunks already written while the position is unchanged, so retrying the same data is idempotent.Validation
Linux, Python 3.12, real libjfs, SQLite meta + local file storage:
pysdk_test.py: 64 tests; onlyWarmupTests.test_basic_warmupfails, and it fails identically on the base commit (local cache environment).Wall time also dropped (test: ~36s → ~23s). The remaining ~1G with buffering comes from the pre-existing
memoryview.tobytes()copy inwrite(), to be handled separately.