Re: limit for mmaping for readfile (Bug #19749)
| From: | Andi Gutmans | Date: | Wed, 21 Apr 2004 11:33:00 +0000 |
| Subject: | Re: limit for mmaping for readfile (Bug #19749) | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-9459@lists.php.net to get a copy of this message | ||
At 12:10 PM 4/21/2004 +0100, Wez Furlong wrote:
Andi, Do you think mmap'ing a series of smaller chunks is going to be faster than mmap'ing the whole file, or faster than reading chunks conventionally? (just asking; I've not done any tests)I'm saying that mmap'ing chunks which are relatively big such as 256KB-1MB, is not much slower than mmap()'ing the whole file in one go.
The mmap code in the passthru function will fall back on reading chunks in a loop if the mmap failed. The proposed mmap limit really just a runaway brake to avoid the box swapping to death if, say, 5 people start downloading 5 .iso images through a PHP script using readfile(). My patch is "nice" at this stage in the release because it is a minimal change that can't hurt anything; tweaking the passthru code is a bit more worrying :/In that case, I'd put a hardcoded limit after which you fallback to non-mmap()'ed reading and not add an INI option. Then you can add the tweaked code when you have time/energy. Andi