Skip to content

sdk/python: avoid oversized read-all buffers for small files - #7899

Merged
jiefenghuang merged 2 commits into
juicedata:mainfrom
adenzhou1350:codex/small-sdk-readall-buffer-20261121
Nov 24, 2026
Merged

jiefenghuang merged 2 commits into
juicedata:mainfrom
adenzhou1350:codex/small-sdk-readall-buffer-20261121

Conversation

@adenzhou1350

@adenzhou1350 adenzhou1350 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Problem

f.read() allocates a 4 MiB buffer even for a small file and again to discover EOF. This also affects ordinary json.load() through the default buffered text wrapper; it is separate from the readinto() path fixed in #7865.

Change

Use the known remaining file length as an allocation hint, with the normal I/O buffer size as a floor. Keep the 4 MiB ceiling and continue reading until native EOF. Add memory, partial-read and sparse multi-chunk regressions, plus English/Chinese SDK notes.

Validation

  • Same 20 selected SDK test instances on main 23d2a456: original 19 pass/1 memory-regression failure; candidate 20 pass, no errors/skips. Local fixtures used private SQLite/local files, Python 3.12 and a reused libjfs build.
  • A/B/B/A warm small-JSON screen: 200 read/parse/close calls take 53.3–55.8 ms before versus 13.0–13.7 ms after (five blocks/process). Traced Python peak: 4,332,242 → 146,130 bytes; process RSS is essentially unchanged. This is a local SDK screen, not production-storage throughput.
  • Complete official SDK CI jobs passed on Redis, MySQL, TiKV. This includes fresh SDK builds, pysdk_test.py and subsequent property tests.
  • Applicable pinned whitespace hooks and git diff --check pass. Existing SDK CI selects the new tests.

AI-assisted source audit and patch/test preparation; results independently executed.

@zxh326
zxh326 removed the request for review from CaitinChen November 23, 2026 07:18
@jiefenghuang
jiefenghuang merged commit 67f9e70 into juicedata:main Nov 24, 2026
29 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.

3 participants