Skip to content

Fix #80061: Copying large files may have suboptimal performance #6078

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

Closed
wants to merge 3 commits into from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Sep 4, 2020

Instead of attempting to map large files into memory at once, we map
chunks of at most PHP_STREAM_MMAP_MAX bytes, and repeat that until we
hit the point where php_stream_seek() fails (see bug 54902), and copy
the rest of the file by reading and writing small chunks.

We also fix the mapping behavior for zero bytes on Windows, which did
not error (as with mmap()), but would have mapped the remaining file.

Instead of attempting to map large files into memory at once, we map
chunks of at most `PHP_STREAM_MMAP_MAX` bytes, and repeat that until we
hit the point where `php_stream_seek()` fails (see bug 54902), and copy
the rest of the file by reading and writing small chunks.

We also fix the mapping behavior for zero bytes on Windows, which did
not error (as with `mmap()`), but would have mapped the remaining file.
@cmb69 cmb69 marked this pull request as ready for review September 4, 2020 22:53
@cmb69 cmb69 changed the title Fix mmap copying Fix #80061: Copying large files may have suboptimal performance Sep 8, 2020
@cmb69 cmb69 added the Bug label Sep 8, 2020
@cmb69 cmb69 requested a review from nikic September 21, 2020 09:36
@cmb69
Copy link
Member Author

cmb69 commented Sep 21, 2020

Thanks! Applied as 19c8445.

@cmb69 cmb69 closed this Sep 21, 2020
@cmb69 cmb69 deleted the cmb/80061 branch September 21, 2020 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants