Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

IO copy API for stream copying #20399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
bukka wants to merge 10 commits into php:master
base: master
Choose a base branch
Loading
from bukka:io_copy
Draft

IO copy API for stream copying #20399

bukka wants to merge 10 commits into php:master from bukka:io_copy

Conversation

@bukka
Copy link
Member

@bukka bukka commented Nov 5, 2025

This introduces new API for fd copying and modifies php_stream_copy_to_stream_ex to use it. The implementation is separated for various platforms and the end result have couple of implications:

  • sendfile is used for copying file to generic fd (e.g. sockets) on linux, bsd, macos and solaris (it uses sendfilev actually)
  • splice is used for copying between generic fds (e.g. sockets) on linux
  • copy_file_range should get used on alpine linux with directly using syscall (as musl does not seem to implement it)
  • copy_file_range is used in the loop so it is used multiple times for files bigger than 2GB on linux
  • file mmap for copying is removed as it allowed crashing PHP when another process modified mapped file - this was used as a fallback for file copying which is no longer needed and sendfile is used for file copying to stream which should be also more effective
  • TransmitFile is used on Windows for copying file to generic fd (socket)
  • file to file copying was also optimized on Windows with use of ReadFile and WriteFile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /