com php-src: Fix frequent reallocations with many small strings: Zend/zend_alloc.c

From: Date: Tue, 27 Oct 2015 16:07:58 +0000
Subject: com php-src: Fix frequent reallocations with many small strings: Zend/zend_alloc.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-89545@lists.php.net to get a copy of this message
Commit: eb32da13cd4f5dd0dae0e07a8f0b6c42d5678f5f Author: Dmitry Stogov <dmitry@zend.com> Tue, 27 Oct 2015 16:53:17 +0100 Committer: Anatol Belski <ab@php.net> Tue, 27 Oct 2015 17:07:58 +0100 Parents: 0e50a4c0086b628ce76de2156d33133595703082 Branches: PHP-7.0 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=eb32da13cd4f5dd0dae0e07a8f0b6c42d5678f5f Log: Fix frequent reallocations with many small strings Changed paths: M Zend/zend_alloc.c Diff: diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 6120efc..06cda75 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -1462,7 +1462,15 @@ static void *zend_mm_realloc_heap(zend_mm_heap *heap, void *ptr, size_t size, si #if ZEND_DEBUG size = real_size; #endif +#ifdef ZEND_WIN32 + /* On Windows we don't have ability to extend huge block in-place. + * We allocate them with 2MB size granularuty, to avoid many + * reallocatioons whenthey when they are extended by small peaces + */ + new_size = ZEND_MM_ALIGNED_SIZE_EX(size, MAX(REAL_PAGE_SIZE, ZEND_MM_CHUNK_SIZE)); +#else new_size = ZEND_MM_ALIGNED_SIZE_EX(size, REAL_PAGE_SIZE); +#endif if (new_size == old_size) { #if ZEND_DEBUG zend_mm_change_huge_block_size(heap, ptr, new_size, real_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); @@ -1722,7 +1730,15 @@ static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t static void *zend_mm_alloc_huge(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) { +#ifdef ZEND_WIN32 + /* On Windows we don't have ability to extend huge block in-place. + * We allocate them with 2MB size granularuty, to avoid many + * reallocatioons whenthey when they are extended by small peaces + */ + size_t new_size = ZEND_MM_ALIGNED_SIZE_EX(size, MAX(REAL_PAGE_SIZE, ZEND_MM_CHUNK_SIZE)); +#else size_t new_size = ZEND_MM_ALIGNED_SIZE_EX(size, REAL_PAGE_SIZE); +#endif void *ptr; #if ZEND_MM_LIMIT

« previous php.cvs (#89545) next »