Skip to content

fast_io.rs: use splice if copy_file_range is not supported - #459

Open
Franklin-Qi wants to merge 2 commits into
uutils:mainfrom
Franklin-Qi:fix-#443-use-sendfile-or-splice-if-copy-file-range-is-not-supported
Open

Franklin-Qi wants to merge 2 commits into
uutils:mainfrom
Franklin-Qi:fix-#443-use-sendfile-or-splice-if-copy-file-range-is-not-supported

Conversation

@Franklin-Qi

@Franklin-Qi Franklin-Qi commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

fast_io.rs: use splice if copy_file_range is not supported

  • Prefer splice (via rustix) for file→pipe output, and enlarge the pipe buffer when possible.
  • Fall back in reliable_copy_file_range with copy_file_range → splice (middle pipe) → write, advancing in_ptr correctly after a partial copy.
  • Cover the paths with Linux unit tests and an end-to-end large-file pipe-through-sed test.
  • If splice becomes unsupported after some bytes were already sent, return Some(copied) so the write fallback only emits the remainder.

Closes: #443

@codecov

codecov Bot commented Jun 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.14056% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.93%. Comparing base (f7fb0d7) to head (49fe557).

Files with missing lines Patch % Lines
src/sed/fast_io.rs 85.02% 37 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #459      +/-   ##
==========================================
+ Coverage   83.86%   83.93%   +0.06%     
==========================================
  Files          14       14              
  Lines        7203     7444     +241     
  Branches      424      438      +14     
==========================================
+ Hits         6041     6248     +207     
- Misses       1157     1191      +34     
  Partials        5        5              
Flag Coverage Δ
macos_latest 85.00% <92.00%> (+0.02%) ⬆️
ubuntu_latest 85.20% <85.36%> (+0.03%) ⬆️
windows_latest 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@Franklin-Qi
Franklin-Qi force-pushed the fix-#443-use-sendfile-or-splice-if-copy-file-range-is-not-supported branch from cee18ce to 581e725 Compare June 5, 2026 07:57
@oech3

oech3 commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

sendfile is internally splice. So no worth to try it. splice with middler pipe is faster.

@oech3

oech3 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Please use rustix instead of unsafe libc.

Comment thread src/sed/fast_io.rs Outdated
Comment thread src/sed/fast_io.rs Outdated
Comment thread src/sed/fast_io.rs Outdated
Comment thread src/sed/fast_io.rs Outdated
Comment thread src/sed/fast_io.rs Outdated
Comment thread src/sed/fast_io.rs Outdated
@sylvestre

Copy link
Copy Markdown
Contributor

@Franklin-Qi sorry, it needs to be rebased

@Franklin-Qi
Franklin-Qi force-pushed the fix-#443-use-sendfile-or-splice-if-copy-file-range-is-not-supported branch from 581e725 to bd5b0e2 Compare August 12, 2026 00:35
@codspeed

codspeed Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 11 untouched benchmarks


Comparing Franklin-Qi:fix-#443-use-sendfile-or-splice-if-copy-file-range-is-not-supported (49fe557) with main (f7fb0d7)

Open in CodSpeed

@Franklin-Qi
Franklin-Qi force-pushed the fix-#443-use-sendfile-or-splice-if-copy-file-range-is-not-supported branch 5 times, most recently from 7551756 to 1889db5 Compare August 12, 2026 01:34
Comment thread src/sed/fast_io.rs Outdated
Comment thread src/sed/fast_io.rs Outdated
Comment thread src/sed/fast_io.rs Outdated
Comment thread src/sed/fast_io.rs Outdated
Comment thread src/sed/fast_io.rs Outdated
Comment thread src/sed/fast_io.rs
@oech3

oech3 commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

remove sendfile from PR's title and the commit message.

@sylvestre

Copy link
Copy Markdown
Contributor

@Franklin-Qi ping?

@Franklin-Qi

Copy link
Copy Markdown
Contributor Author

@Franklin-Qi ping?

Yeah, I will deal with this issue soon. @sylvestre

Comment thread src/sed/fast_io.rs Outdated
Comment thread src/sed/fast_io.rs Outdated
Comment thread src/sed/fast_io.rs Outdated
Comment thread src/sed/fast_io.rs
Comment thread src/sed/fast_io.rs Outdated
Comment thread src/sed/fast_io.rs Outdated
Comment thread src/sed/fast_io.rs Outdated
- Prefer splice (via rustix) for file→pipe output, and enlarge the
  pipe buffer when possible.
- Fall back in reliable_copy_file_range with
  copy_file_range → splice (middle pipe) → write, advancing in_ptr
  correctly after a partial copy.
- Cover the paths with Linux unit tests and an end-to-end large-file
  pipe-through-sed test.

Closes: uutils#443
@Franklin-Qi
Franklin-Qi force-pushed the fix-#443-use-sendfile-or-splice-if-copy-file-range-is-not-supported branch from 1889db5 to 9628ac1 Compare September 30, 2026 11:03
@Franklin-Qi Franklin-Qi changed the title fast_io.rs: use sendfile or splice if copy_file_range is not supported fast_io.rs: use splice if copy_file_range is not supported Sep 30, 2026
If splice becomes unsupported after some bytes were already sent,
return Some(copied) so the write fallback only emits the remainder.
@Franklin-Qi
Franklin-Qi force-pushed the fix-#443-use-sendfile-or-splice-if-copy-file-range-is-not-supported branch from 9628ac1 to 49fe557 Compare September 30, 2026 11:22
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.

fast_io.rs: use sendfile or splice if copy_file_range is not supported

3 participants