Bug #18029 Updated: Echoing long strings :: long echo times over a number of characters

From: Date: Wed, 10 Jul 2002 17:54:29 +0000
Subject: Bug #18029 Updated: 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-13757@lists.php.net to get a copy of this message
 ID:               18029
 Updated by:       van.binsbergen@taktik.ch
 Reported By:      wrestlecar@hotmail.com
 Status:           Bogus
 Bug Type:         Performance problem
 Operating System: Linux
 PHP Version:      4.2.1
 New Comment:

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


Previous Comments:
------------------------------------------------------------------------

[2002-06-28 00:54:13] wrestlecar@hotmail.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@hotmail.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 http://bugs.php.net/?id=18029&edit=1



Thread (4 messages)

« previous php.bugs (#13757) next »