ID: 33070
Comment by: jeff at vertexdev dot com
Reported By: lindsay at bitleap dot com
Status: Open
Bug Type: Performance problem
Operating System: Linux 2.6.10 kernel
PHP Version: 5.0.3
New Comment:
The fix is really easy. In function bzdecompress, you need to do the
following:
1. Before the 'do' loop, initialize size to some reasonable value:
size = PHP_BZ_DECOMPRESS_SIZE;
2. Inside of the loop, double the size each time (replace the existing
'size = dest_len * iter;' statement with this):
size *= 2;
This will temporarily use up a little bit more memory than stricly
necessary, but it will make the function usable.
Drop me an email if you need more information.
Previous Comments:
------------------------------------------------------------------------
[2005-05-22 22:04:49] [EMAIL PROTECTED]
Yes, this is possibel with the BZ2_bzRead() api call.
------------------------------------------------------------------------
[2005-05-22 20:56:20] lindsay at bitleap dot com
Given that bzip can be used in a stream, could the data be decompressed
in chunks?
------------------------------------------------------------------------
[2005-05-22 15:20:22] [EMAIL PROTECTED]
And how do you think it should work?
I don't see any more effective way that will not hit memory instead of
CPU usage.
------------------------------------------------------------------------
[2005-05-20 16:56:48] lindsay at bitleap dot com
Script:
<?php
decrypt( "256K", file_get_contents("256K.bz2", "r"));
decrypt( "512K", file_get_contents("512K.bz2", "r"));
decrypt( "1M", file_get_contents("1M.bz2", "r"));
decrypt( "2M", file_get_contents("2M.bz2", "r"));
decrypt( "3M", file_get_contents("3M.bz2", "r"));
decrypt( "4M", file_get_contents("4M.bz2", "r"));
function decrypt($file_name, $file_data)
{
echo "file length $file_name ran in: ";
$time_start = time();
bzdecompress($file_data, false);
$end_start = time();
echo ($end_start - $time_start) . " seconds\n";
}
?>
Data:
If you run linux:
dd if=/dev/urandom bs=1024 count=256 of=256K
dd if=/dev/urandom bs=1024 count=512 of=512K
dd if=/dev/urandom bs=1024 count=1024 of=1M
dd if=/dev/urandom bs=1024 count=2048 of=2M
dd if=/dev/urandom bs=1024 count=3072 of=3M
dd if=/dev/urandom bs=1024 count=4096 of=4M
bzip2 256K 512K 1M 2M 3M 4M
If not, let me know and I'll upload or email data samples.
------------------------------------------------------------------------
[2005-05-19 23:44:05] [EMAIL PROTECTED]
Please provide a short but complete reproduce script and (if possible)
the data too.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/33070
--
Edit this bug report at http://bugs.php.net/?id=33070&edit=1