Skip to content

Fix prefetch re-reading already-cached chunks off disk - #10

Merged
zeehio merged 2 commits into
mainfrom
claude/fuse4dbricks-code-review-qnhxtw
Aug 6, 2026
Merged

zeehio merged 2 commits into
mainfrom
claude/fuse4dbricks-code-review-qnhxtw

Conversation

@zeehio

@zeehio zeehio commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • DataManager._process_request() checked whether a prefetched chunk needed downloading by calling persistence.retrieve_chunk(), which reads the chunk's full content back from disk — for every prefetch request, not just on-demand reads. Since chunk_size is 8 MB and a FUSE read() call is much smaller, the prefetch window (10 chunks ahead) stays the same across dozens of consecutive read() calls while the cursor crawls through one chunk, so each of those calls re-triggered a full-chunk disk read for content that was already on disk and never even entered the RAM cache.
  • Net effect: reading a large file sequentially through the mount could read roughly an order of magnitude more bytes off local disk than the file actually contains, sustained for the life of the read.
  • Added DiskPersistence.chunk_exists(), a plain existence check with no content read, and prefetch now uses it instead of retrieve_chunk() to decide whether a download is needed. Prefetch still deliberately does not populate the RAM cache — the download (network I/O) is the point of prefetching; caching a chunk that may never be read is not.

Test plan

  • uv run pytest -q — 389 passed, 26 skipped (skips are live-API tests requiring real Databricks credentials, unaffected by this change)
  • uv run ruff check — clean
  • uv run mypy fuse4dbricks/fs/data_manager.py fuse4dbricks/storage/persistence.py — clean
  • Added 7 new tests covering both the on-demand ("high" priority, reads+caches in RAM) and prefetch ("regular" priority, existence-check-only, never cached in RAM) paths in _process_request, plus DiskPersistence.chunk_exists() directly (including a test that asserts it never reads the file's content)

🤖 Generated with Claude Code

https://claude.ai/code/session_019abzZUvVSrhjHUFgZj9L4s


Generated by Claude Code

claude added 2 commits August 6, 2026 17:05
_process_request checked whether a chunk needed downloading by calling
retrieve_chunk(), which reads the chunk's full content back from disk
-- for every prefetch request, not just on-demand reads. Since
chunk_size is 8 MB and a FUSE read() call is much smaller, the
prefetch window (10 chunks ahead) stayed the same across dozens of
consecutive read() calls while the cursor crawled through one chunk,
and each of those calls re-triggered a full-chunk disk read for
content that was already on disk and never even entered the RAM
cache (only "high priority" on-demand reads were cached in RAM).

Net effect: reading a large file sequentially through the mount could
read roughly an order of magnitude more bytes off local disk than the
file actually contains, sustained for the life of the read.

Prefetch now uses DiskPersistence.chunk_exists(), a plain existence
check, to decide whether a download is needed, and still deliberately
does not populate the RAM cache -- the download (network I/O) is what
prefetch is for; caching a chunk that may never be read is not.
@zeehio
zeehio merged commit 5f736d5 into main Aug 6, 2026
2 checks passed
zeehio added a commit that referenced this pull request Aug 7, 2026
…hxtw

Fix prefetch re-reading already-cached chunks off disk
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