summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2015-10-27 16:53:17 +0100
committerAnatol Belski <ab@php.net>2015-10-27 09:52:43 +0100
commitae79c52c123f4ce04a82873bf2f14a8335f8f34a (patch)
tree2bc1ff99c4642b1fc12d1b1fc4e8f46a660b0fbc
parent579f10c0a1bf0331256ba7b12b8a9dd78c14ef1f (diff)
downloadphp-git-php-7.0.0RC6.tar.gz
Fix frequent reallocations with many small stringsphp-7.0.0RC6
-rw-r--r--Zend/zend_alloc.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index 6120efc15c..06cda75363 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