Bug #18029 [Com]: Echoing long strings :: long echo times over a number of characters
| From: | php4fan at gmail dot com | Date: | Mon, 25 Jan 2021 20:46:01 +0000 |
| Subject: | Bug #18029 [Com]: Echoing long strings :: long echo times over a number of characters | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-231768@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=18029&edit=1
ID: 18029
Comment by: php4fan at gmail dot com
Reported by: wrestlecar at hotmail dot com
Summary: Echoing long strings :: long echo times over a
number of characters
Status: Not a bug
Type: Bug
Package: Performance problem
Operating System: Linux
PHP Version: 4.2.1
Block user comment: N
Private report: N
New Comment:
F*****g unbelievable.
It's been EIGHTEEN and a half year, and this is still an issue.
Why the **** was this closed?
So what if this is due to Nagle's Algorithm?? Just split the string into smaller ones and send
them! It fixes the issue if I do that in my code, so why shouldn't you just do it internally?
Previous Comments:
------------------------------------------------------------------------
[2002-07-10 13:54:29] van dot binsbergen at taktik dot ch
Hi wrestlecar
Very glad I found someone who met this problem also! I found on my system (also using 4.2.1) that
the "breakpoint" is exactly at 8182 characters! (Where as this seems to be about 15000 in
your system).
>It appears the issue is related to the Nagle Algorithm and how it
>affects TCP/IP transmissions of small packets done separately versus
>large packets.
Maybe, but it is a bug anyway!
Urs
------------------------------------------------------------------------
[2002-06-28 00:54:13] wrestlecar at hotmail dot com
It appears the issue is related to the Nagle Algorithm and how it affects TCP/IP transmissions of
small packets done separately versus large packets.
------------------------------------------------------------------------
[2002-06-27 19:43:02] wrestlecar at hotmail dot com
I have discovered a problem that is most likely related to PHP and the echo statement, but it is
possible that it is a server configuration issue as well.
When echoing long strings, the server has no problem until it gets to a certain window of
characters, this ranges depending on the load of the server but is usually around 15,000 characters.
For example, take a look at these page generation times for a custom script that was developed to
investigate this issue( the load average on the server was about the same when all tests were
taken). The times listed below are simply to echo one string with the number of characters
indicated.
Display Length: 14201 characters.
Display Output: 0.00199 seconds.
Display Length: 14251 characters.
Display Output: 0.00159 seconds.
Display Length: 14301 characters.
Display Output: 0.12694 seconds.
Display Length: 14401 characters.
Display Output: 0.13424 seconds.
Now, getting to the really awkward part. If the string is "exploded" by linebreak, and
then echoed in a loop line by line, the processing time is roughly 4x FASTER than that of echoing
the single statement, this has been verified by another script I developed.
This behavior is not present on everyone's system, it has been tested on several systems using
the same script and this was the worse case, while some other systems did display similar results.
Here is the test script that was used to identify the problem:
<?php
for( $i = 0; $i <= 20000; $i++)
{
$example_output .= '1';
}
$microtime = explode(' ', microtime());
$startTime = $microtime[0] + $microtime[1];
echo $example_output;
$microtime = explode(' ', microtime());
$endTime = $microtime[0] + $microtime[1];
echo 'Display Length: ', strlen($example_output), ' characters.<br>';
echo 'Display Output: ', round($endTime - $startTime, 5), ' seconds.';
?>
In the script, simply replace the 20000 with whatever number you wish to check.
Below are a few posts I made on forums inquiring about this issue, and may provide some small
details by the other users that I did not pick up on.
http://www.sitepointforums.com/showthread.php?threadid=65280
http://www.invisionboard.com/forums/index.php?s=&act=ST&f=7&t=12538
Unfortunately, since the server is not my own and is a shared server, I do not have a list of the
modules PHP was installed with, but here is some information on the server.
Status: http://dragon.nocdns.com
PHPInfo: http://dragon.nocdns.com/phpinfo/
Thank you for your assistance.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=18029&edit=1