Skip to content

open_object: block_size=0 replaces the read_ahead flag - #2126

Merged
shcheklein merged 2 commits into
mainfrom
refactor/open-block-size-zero
Oct 29, 2026
Merged

shcheklein merged 2 commits into
mainfrom
refactor/open-block-size-zero

Conversation

@shcheklein

Copy link
Copy Markdown
Contributor

Follow-up to #2095, from @dmpetrov's review (point 5): open_object had two options for one setting. block_size (#2028) sets the read-ahead block, and read_ahead=False (#2095) turned read-ahead off.

Change: block_size=0 now turns read-ahead off, and read_ahead is gone. Each read then fetches only the bytes asked for. None still means the filesystem default (50 MiB on S3), and a positive value sets the block size.

  • The client translates 0 into cache_type="none" and doesn't pass block_size=0 to fsspec. Filesystems treat 0 differently: HfFileSystem opens a stream that can't seek, which breaks pyarrow on the Parquet footer.
  • Behavior is unchanged: _PartialReadHandler passes block_size=0, which gives fsspec the same arguments as read_ahead=False did.
  • File.open(block_size=0) already forwarded to open_object. The docstring now mentions 0.
  • HTTP ignores block_size, as before.

Tests:

  • New: test_open_object_huggingface_block_size_zero_reads_only_asked_bytes seeks and fetches only the asked range. It fails on main with Cannot seek streaming HF file.
  • The HF client setup moved into an hf_archive_client fixture shared with the tar read-ahead test.

🤖 Generated with Claude Code

`open_object` had two options for one setting: `block_size` sets the
read-ahead block, and `read_ahead=False` turned read-ahead off. Now
`block_size=0` turns it off and `read_ahead` is gone.

The client translates 0 to `cache_type="none"` instead of passing it to
fsspec: HfFileSystem opens a stream that can't seek for block_size=0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Deploying datachain with  Cloudflare Pages  Cloudflare Pages

Latest commit: 48066f7
Status: ✅  Deploy successful!
Preview URL: https://4de92946.datachain-2g6.pages.dev
Branch Preview URL: https://refactor-open-block-size-zer.datachain-2g6.pages.dev

View logs

@codspeed

codspeed Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 6 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 9 untouched benchmarks


Comparing refactor/open-block-size-zero (48066f7) with main (6c8244c)

Open in CodSpeed

@codecov

codecov Bot commented Oct 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@dreadatour dreadatour left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me 👍 I like the idea of simplifying this.

@shcheklein
shcheklein merged commit 8f0cf9d into main Oct 29, 2026
36 checks passed
@shcheklein
shcheklein deleted the refactor/open-block-size-zero branch October 29, 2026 00:29
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