Improved Zend Memory Manager to guarantee reasonable time for worst cases of best-fit free block searching algorithm.

This commit is contained in:
Dmitry Stogov 2007-03-20 06:46:48 +00:00
parent 13aac95bfc
commit d514bf27a6
5 changed files with 673 additions and 338 deletions

5
NEWS
View file

@ -9,6 +9,8 @@ PHP NEWS
- Upgraded SQLite 3 to version 3.3.13 (Ilia)
- Upgraded PCRE to version 7.0 (Nuno)
- Updated timezone database to version 2007.3. (Derick)
- Improved Zend Memory Manager to guarantee reasonable time for worst cases
of best-fit free block searching algorithm. (Dmitry)
- Improved SPL (Marcus)
. Added SplFileInfo::getBasename(), DirectoryIterator::getBasename().
. Added SplFileInfo::getLinkTarget(), SplFileInfo::getRealPath().
@ -29,6 +31,7 @@ PHP NEWS
via __get()). (Dmitry)
- Fixed bug #40815 (using strings like "class::func" and static methods in
set_exception_handler() might result in crash). (Tony)
- Fixed bug #40809 (Poor perfomance of ".="). (Dmitry)
- Fixed bug #40805 (Failure executing function ibase_execute()). (Tony)
- Fixed bug #40800 (cannot disable memory_limit with -1). (Dmitry, Tony)
- Fixed bug #40794 (ReflectionObject::getValues() may crash when used with
@ -90,6 +93,8 @@ PHP NEWS
- Fixed Bug #40352 (FCGI_WEB_SERVER_ADDRS function get lost). (Dmitry)
- Fixed bug #40286 (PHP fastcgi with PHP_FCGI_CHILDREN don't kill children when
parent is killed). (Dmitry)
- Fixed bug #40261 (Extremely slow data handling due to memory fragmentation).
(Dmitry)
- Fixed bug #40236 (php -a function allocation eats memory). (Dmitry)
- Fixed bug #40109 (iptcembed fails on non-jfif jpegs). (Tony)
- Fixed bug #39836 (SplObjectStorage empty after unserialize). (Marcus)

25
Zend/tests/bug40261.phpt Executable file
View file

@ -0,0 +1,25 @@
--TEST--
Bug #40261 (Extremely slow data handling due to memory fragmentation)
--INI--
memory_limit=128M
--FILE--
<?php
$num = 100000;
$a = Array();
for ($i=0; $i<$num; $i++) {
$a[$i] = Array(1);
}
for ($i=0; $i<$num; $i++) {
$b[$i] = $a[$i][0];
}
unset($a);
for ($i=0; $i<$num; $i++) {
$b[$i] = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
}
echo "ok\n";
?>
--EXPECT--
ok

33
Zend/tests/bug40809.phpt Executable file
View file

@ -0,0 +1,33 @@
--TEST--
Bug #40809 Poor perfomance of ".="
--FILE--
<?php
error_reporting(E_ALL|E_STRICT);
$num_increments = 100;
$num_repeats = 1000;
$increment = 50;
/* Create some more holes to give the memory allocator something to
* work with. */
$num = 5000;
$a = Array();
for ($i=0; $i<$num; $i++) {
$a[$i] = Array(1);
}
for ($i=0; $i<$num; $i++) {
$b[$i] = $a[$i][0];
}
unset($a);
for ($i=0;$i<$num_repeats;$i++) {
$evil = "";
for ($j=0;$j<$num_increments;$j++) {
$evil .= str_repeat("a", $increment);
}
unset($evil);
}
echo "ok\n";
?>
--EXPECT--
ok

File diff suppressed because it is too large Load diff

View file

@ -228,8 +228,9 @@ struct _zend_mm_storage {
void *data;
};
ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_mem_handlers *handlers, size_t block_size, void *params);
ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_mem_handlers *handlers, size_t block_size, size_t reserve_size, int internal, void *params);
ZEND_API zend_mm_heap *zend_mm_set_heap(zend_mm_heap *new_heap TSRMLS_DC);
ZEND_API zend_mm_storage *zend_mm_get_storage(zend_mm_heap *heap);
#endif