Implement cross-file persistent chunk cache#118
Draft
Copilot wants to merge 3 commits into
Draft
Conversation
Add a persistent, disk-backed chunk cache keyed by (xorbHash, absoluteChunkIndex) that is owned by the client and shared across all download methods (DownloadFile, DownloadFileV1, DownloadFileV2, DownloadFiles). New types and options: - download.ChunkCache: persistent cache backed by filesystem - download.WithChunkCache(): download option - client.WithChunkCache(): client option Integration in prefetcher: - On cache hit: skip network download and decoding entirely - On cache miss: download and decode as normal, then write to cache - Cache is recoverable after process restart (plain files on disk) - No LRU or capacity limit Agent-Logs-Url: https://github.com/wzshiming/xet/sessions/2519e980-2e44-447e-9f63-f4a696a5d0ae Co-authored-by: wzshiming <6565744+wzshiming@users.noreply.github.com>
…x test edge case Agent-Logs-Url: https://github.com/wzshiming/xet/sessions/2519e980-2e44-447e-9f63-f4a696a5d0ae Co-authored-by: wzshiming <6565744+wzshiming@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement a cross-file chunk cache for reusable downloads
Implement cross-file persistent chunk cache
Apr 17, 2026
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.
Add a client-level, disk-backed chunk cache keyed by
(xorbHash, absoluteChunkIndex)that is reused across all download methods and survives process restarts. No LRU or capacity limit.Cache layer (
download/persistent_cache.go)ChunkCachestores decoded chunks as files under<dir>/<xorbHash>/<chunkIndex>Get,Put,HasRangeAPIPrefetcher integration (
download/prefetcher.go)prefetchEntrynow tracks absolute chunk range (chunkStart/chunkEnd) derived fromtermFetchestryLoadFromCachechecksHasRange; on hit, creates achunkCachebacked bypersistentRead— no network fetch, no decodingsaveToCachewrites decoded chunks afterLoadAll()in both single-range and multipart (stream) pathschunkCacheextension (download/chunk_cache.go)persistentRead func(idx uint32) ([]byte, error)— when set,Chunk()bypasses the decoder/temp-file store entirelyClient wiring
client.WithChunkCache(*download.ChunkCache)option, plumbed throughdownload.WithChunkCache()to all four download entry points (DownloadFile,DownloadFileV1,DownloadFileV2,DownloadFiles)Usage