com php-src: Fix bug #77930: Remove mmap limit: NEWS main/streams/mmap.c
| From: | Nikita Popov | Date: | Thu, 31 Oct 2019 08:37:05 +0000 |
| Subject: | com php-src: Fix bug #77930: Remove mmap limit: NEWS main/streams/mmap.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-109146@lists.php.net to get a copy of this message | ||
Commit: 333d607d47ca6eec96637c1c8686591dec6f5a0b
Author: Nikita Popov <nikita.ppv@gmail.com> Wed, 30 Oct 2019 13:15:05 +0100
Parents: 0055f1e3dc7ec27778d6d3bd22404319b3ceeeca
Branches: PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=333d607d47ca6eec96637c1c8686591dec6f5a0b
Log:
Fix bug #77930: Remove mmap limit
First, the limitation already doesn't trigger if you copy the whole
file (i.e. use copy() or stream_copy_to_stream() and don't specify
a length). This happens because length will be 0 at the time of the
check and only later calculated based on the file size. This means
that we're already completely blowing the length limit for what is
likely the most common case, and it doesn't seem like anyone complained
about that.
Second, the premise of the code comment ("to avoid runaway swapping")
seems incorrect to me. Because this performs a file-backed non-private
mmap, no swap backing is needed for the mapping. Concerns over "memory
usage" are also misplaced, as this is a virtual mapping.
Bugs:
https://bugs.php.net/77930
Changed paths:
M NEWS
M main/streams/mmap.c
Diff:
diff --git a/NEWS b/NEWS
index b63d82438c8..a344936ce21 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 7.4.0RC6
+- Standard:
+ . Fixed bug #77930 (stream_copy_to_stream should use mmap more often).
+ (Nikita)
31 Oct 2019, PHP 7.4.0RC5
diff --git a/main/streams/mmap.c b/main/streams/mmap.c
index 8f3fcf97a69..63bae875057 100644
--- a/main/streams/mmap.c
+++ b/main/streams/mmap.c
@@ -29,12 +29,6 @@ PHPAPI char *_php_stream_mmap_range(php_stream *stream, size_t offset, size_t le
range.mode = mode;
range.mapped = NULL;
- /* For now, we impose an arbitrary limit to avoid
- * runaway swapping when large files are passed through. */
- if (length > 4 * 1024 * 1024) {
- return NULL;
- }
-
if (PHP_STREAM_OPTION_RETURN_OK == php_stream_set_option(stream, PHP_STREAM_OPTION_MMAP_API,
PHP_STREAM_MMAP_MAP_RANGE, &range)) {
if (mapped_len) {
*mapped_len = range.length;