Skip to content

fstree: never copy to io.Discard unless dealing with compression#4016

Open
roman-khimov wants to merge 1 commit into
masterfrom
fstree-ranges
Open

fstree: never copy to io.Discard unless dealing with compression#4016
roman-khimov wants to merge 1 commit into
masterfrom
fstree-ranges

Conversation

@roman-khimov

@roman-khimov roman-khimov commented Jun 12, 2026

Copy link
Copy Markdown
Member

This suggests compression is harmful, so it better be dropped. But that's subject to some subsequent PR.

@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.25641% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 27.75%. Comparing base (6241c4c) to head (71faf77).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
pkg/local_object_storage/blobstor/fstree/util.go 48.97% 24 Missing and 1 partial ⚠️
pkg/local_object_storage/blobstor/fstree/fstree.go 40.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4016      +/-   ##
==========================================
- Coverage   27.79%   27.75%   -0.04%     
==========================================
  Files         681      681              
  Lines       46797    46942     +145     
==========================================
+ Hits        13006    13031      +25     
- Misses      32553    32669     +116     
- Partials     1238     1242       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI 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.

Pull request overview

This PR refactors FSTree read/range-stream handling to avoid falling back to io.CopyN(io.Discard, ...) when skipping data for non-compressed objects, by switching internal readers to seek-capable wrappers.

Changes:

  • Introduces seek-capable reader wrappers (prefixedReadSeekCloser, limitedFileReader) and a zstd compressedReader.
  • Changes internal object reading helpers to return io.ReadSeekCloser to enable skipping via Seek.
  • Updates payload prefix/range handling to use the new wrappers instead of io.MultiReader + io.LimitReader compositions.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
pkg/local_object_storage/blobstor/fstree/util.go Adds new reader wrapper types used to prefix/limit streams and handle compressed reads.
pkg/local_object_storage/blobstor/fstree/head.go Switches internal read paths to return seek-capable readers and uses new prefix wrapper.
pkg/local_object_storage/blobstor/fstree/fstree.go Updates range-shifting logic to use Seek and new limiting/prefix wrappers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/local_object_storage/blobstor/fstree/util.go
Comment thread pkg/local_object_storage/blobstor/fstree/util.go
@@ -579,7 +579,7 @@ func (t *FSTree) readPayloadRange(addr oid.Address, off, ln uint64, getHdrBuf fu
return pldLen, stream, nil

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

True, but I don't want any additional wrappers. Current users are well known.

FSTree routinely creates io.MultiReader in many places and the probelm is
that it does not and can not implement Seek(), so every time we're trying
to get a range stream we're effectively reading and discarding everything
which is not very productive.

This patch introduces a new set of wrappers with Seek() implemented. These
implementations are not complete, it's more of Skip() rather than Seek(),
but that's the only thing we really need and this allows to reuse the same
io.ReadSeekCloser everywhere (implemented natively by os.File).

Signed-off-by: Roman Khimov <roman@nspcc.ru>
@roman-khimov roman-khimov added this to the v0.54.0 milestone Jun 12, 2026
@roman-khimov roman-khimov marked this pull request as ready for review June 12, 2026 16:37
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