36 points · by vlucas · 14y ago · 29 comments
http://svn.php.net/viewvc/php/php-src/trunk/main/output.c?vi...
http://svn.php.net/viewvc/php/php-src/trunk/main/php_output....
#define PHP_OUTPUT_HANDLER_DEFAULT_SIZE 0x4000- if you have to use it, you need to question yourself carefully as to "why" and if there is a better way.
The better question might be "if you want to turn it off, the question is why", or something.
ob_start();
include $file;
$contents = ob_get_contents();
ob_end_clean();Oh Steve Souders, your quest for speed will doom us all:)
What's the best PHP framework/library for that kind of thing?
If data sent over packet network wasn't bufferend, most of the time partial frames would be sent. With buffering, the OS usually sends full frames, making better use of bandwidth, at slight expense of delay and tiny extra memory use. There is even some tunable smarts built-in to keep delay down to manageable size.
The OS tries to create full frames from partial writes from applications. If OS didn't provide that service, it would be up to application to align write size for optimal bandwidth utilization.
You don't really want PHP developers to have to think about size of strings they output, now do you? ;-) For reference, http://www.pbm.com/~lindahl/mel.html -- a guy that hand-picked intervals between instructions in drum memory for better performance -- not exactly the kind of work for typical webdeveloper.
This is one reason why the C++ cognoscenti recommend using std::deque as your default array-like container rather than std::vector.
I haven't looked at PHP's implementation, and I've long since learned not to expect intelligent, rational implementation decisions from that language community, but it's certainly possible to grow by a fixed amount and remain O(N) by never copying elements at all.