]> granicus.if.org Git - php/commitdiff
Fixded bug #72736 (Slow performance when fetching large dataset with mysqli / PDO)
authorDmitry Stogov <dmitry@zend.com>
Wed, 26 Oct 2016 12:17:09 +0000 (15:17 +0300)
committerDmitry Stogov <dmitry@zend.com>
Wed, 26 Oct 2016 12:17:09 +0000 (15:17 +0300)
NEWS
Zend/zend_alloc.c

diff --git a/NEWS b/NEWS
index 20411a64ce8b9aa669744222fcc14602d6b6f6a8..be6738ae74bb64a343b7efe6bb1e5ee7a1f7fb55 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,7 +2,9 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2016 PHP 7.0.14
 
-
+- Core:
+  . Fixded bug #72736 (Slow performance when fetching large dataset with mysqli
+    / PDO). (Dmitry)
 
 10 Nov 2016 PHP 7.0.13
 
index 40eb10046fb386d5c9a329d76f4eef3d7d008023..937340d9c962b0df1ca8516b77e1417a1d3ff332 100644 (file)
@@ -897,6 +897,7 @@ static void *zend_mm_alloc_pages(zend_mm_heap *heap, int pages_count ZEND_FILE_L
 {
        zend_mm_chunk *chunk = heap->main_chunk;
        int page_num, len;
+       int steps = 0;
 
        while (1) {
                if (UNEXPECTED(chunk->free_pages < pages_count)) {
@@ -1073,10 +1074,20 @@ get_chunk:
                        goto found;
                } else {
                        chunk = chunk->next;
+                       steps++;
                }
        }
 
 found:
+       if (steps > 2 && pages_count < 8) {
+               /* move chunk into the head of the linked-list */
+               chunk->prev->next = chunk->next;
+               chunk->next->prev = chunk->prev;
+               chunk->next = heap->main_chunk->next;
+               chunk->prev = heap->main_chunk;
+               chunk->prev->next = chunk;
+               chunk->next->prev = chunk;
+       }
        /* mark run as allocated */
        chunk->free_pages -= pages_count;
        zend_mm_bitset_set_range(chunk->free_map, page_num, pages_count);