From 2e3fc57c5c205e352a805830fd3ec4c7dbfa2efa Mon Sep 17 00:00:00 2001 From: Andrey Hristov Date: Tue, 10 Nov 2015 14:25:06 +0100 Subject: MNDR: - move things out of mysqlnd_priv.h --- ext/mysqlnd/mysqlnd_block_alloc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'ext/mysqlnd/mysqlnd_block_alloc.c') diff --git a/ext/mysqlnd/mysqlnd_block_alloc.c b/ext/mysqlnd/mysqlnd_block_alloc.c index 9a7fdae0f7..95976fca3e 100644 --- a/ext/mysqlnd/mysqlnd_block_alloc.c +++ b/ext/mysqlnd/mysqlnd_block_alloc.c @@ -12,8 +12,7 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Georg Richter | - | Andrey Hristov | + | Authors: Andrey Hristov | | Ulf Wendel | +----------------------------------------------------------------------+ */ -- cgit v1.2.1 From 49493a2dcfb2cd1758b69b13d9006ead3be0e066 Mon Sep 17 00:00:00 2001 From: Lior Kaplan Date: Fri, 1 Jan 2016 19:19:27 +0200 Subject: Happy new year (Update copyright to 2016) --- ext/mysqlnd/mysqlnd_block_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/mysqlnd/mysqlnd_block_alloc.c') diff --git a/ext/mysqlnd/mysqlnd_block_alloc.c b/ext/mysqlnd/mysqlnd_block_alloc.c index e68d80d236..10c6ed6e19 100644 --- a/ext/mysqlnd/mysqlnd_block_alloc.c +++ b/ext/mysqlnd/mysqlnd_block_alloc.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 2006-2015 The PHP Group | + | Copyright (c) 2006-2016 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | -- cgit v1.2.1 From 42fe5e6791bb0adca2b4bc0373007a9f776e3d8a Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 22 Feb 2016 17:33:41 +0100 Subject: Drop mysqlnd mempool refcount This member was no longer used. Also fix handling of from_pool in resize_chunk. It was setting pool to NULL instead of from_pool to FALSE. --- ext/mysqlnd/mysqlnd_block_alloc.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'ext/mysqlnd/mysqlnd_block_alloc.c') diff --git a/ext/mysqlnd/mysqlnd_block_alloc.c b/ext/mysqlnd/mysqlnd_block_alloc.c index 0897c65a64..d92fd755d8 100644 --- a/ext/mysqlnd/mysqlnd_block_alloc.c +++ b/ext/mysqlnd/mysqlnd_block_alloc.c @@ -41,7 +41,6 @@ mysqlnd_mempool_free_chunk(MYSQLND_MEMORY_POOL_CHUNK * chunk) */ pool->free_size += chunk->size; } - pool->refcount--; } else { mnd_efree(chunk->ptr); } @@ -74,8 +73,7 @@ mysqlnd_mempool_resize_chunk(MYSQLND_MEMORY_POOL_CHUNK * chunk, unsigned int siz chunk->ptr = new_ptr; pool->free_size += chunk->size; chunk->size = size; - chunk->pool = NULL; /* now we have no pool memory */ - pool->refcount--; + chunk->from_pool = FALSE; /* now we have no pool memory */ } else { /* If the chunk is > than asked size then free_memory increases, otherwise decreases*/ pool->free_size += (chunk->size - size); @@ -93,8 +91,7 @@ mysqlnd_mempool_resize_chunk(MYSQLND_MEMORY_POOL_CHUNK * chunk, unsigned int siz memcpy(new_ptr, chunk->ptr, chunk->size); chunk->ptr = new_ptr; chunk->size = size; - chunk->pool = NULL; /* now we have non-pool memory */ - pool->refcount--; + chunk->from_pool = FALSE; /* now we have non-pool memory */ } } } else { @@ -136,7 +133,6 @@ MYSQLND_MEMORY_POOL_CHUNK * mysqlnd_mempool_get_chunk(MYSQLND_MEMORY_POOL * pool } } else { chunk->from_pool = TRUE; - ++pool->refcount; chunk->ptr = pool->arena + (pool->arena_size - pool->free_size); /* Last step, update free_size */ pool->free_size -= size; @@ -157,7 +153,6 @@ mysqlnd_mempool_create(size_t arena_size) if (ret) { ret->get_chunk = mysqlnd_mempool_get_chunk; ret->free_size = ret->arena_size = arena_size ? arena_size : 0; - ret->refcount = 0; /* OOM ? */ ret->arena = mnd_emalloc(ret->arena_size); if (!ret->arena) { -- cgit v1.2.1 From 2d1559f827477963a3f8a40af64212a409ba9457 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 22 Feb 2016 18:40:45 +0100 Subject: Move free_chunk and resize_chunk into memory pool Drops 24 bytes from each chunk. For the example in bug #71468 it reduces memory usage by 30%. --- ext/mysqlnd/mysqlnd_block_alloc.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'ext/mysqlnd/mysqlnd_block_alloc.c') diff --git a/ext/mysqlnd/mysqlnd_block_alloc.c b/ext/mysqlnd/mysqlnd_block_alloc.c index d92fd755d8..8729606ade 100644 --- a/ext/mysqlnd/mysqlnd_block_alloc.c +++ b/ext/mysqlnd/mysqlnd_block_alloc.c @@ -28,9 +28,8 @@ /* {{{ mysqlnd_mempool_free_chunk */ static void -mysqlnd_mempool_free_chunk(MYSQLND_MEMORY_POOL_CHUNK * chunk) +mysqlnd_mempool_free_chunk(MYSQLND_MEMORY_POOL * pool, MYSQLND_MEMORY_POOL_CHUNK * chunk) { - MYSQLND_MEMORY_POOL * pool = chunk->pool; DBG_ENTER("mysqlnd_mempool_free_chunk"); if (chunk->from_pool) { /* Try to back-off and guess if this is the last block allocated */ @@ -52,11 +51,10 @@ mysqlnd_mempool_free_chunk(MYSQLND_MEMORY_POOL_CHUNK * chunk) /* {{{ mysqlnd_mempool_resize_chunk */ static enum_func_status -mysqlnd_mempool_resize_chunk(MYSQLND_MEMORY_POOL_CHUNK * chunk, unsigned int size) +mysqlnd_mempool_resize_chunk(MYSQLND_MEMORY_POOL * pool, MYSQLND_MEMORY_POOL_CHUNK * chunk, unsigned int size) { DBG_ENTER("mysqlnd_mempool_resize_chunk"); if (chunk->from_pool) { - MYSQLND_MEMORY_POOL * pool = chunk->pool; /* Try to back-off and guess if this is the last block allocated */ if (chunk->ptr == (pool->arena + (pool->arena_size - pool->free_size - chunk->size))) { /* @@ -115,20 +113,17 @@ MYSQLND_MEMORY_POOL_CHUNK * mysqlnd_mempool_get_chunk(MYSQLND_MEMORY_POOL * pool chunk = mnd_emalloc(sizeof(MYSQLND_MEMORY_POOL_CHUNK)); if (chunk) { - chunk->free_chunk = mysqlnd_mempool_free_chunk; - chunk->resize_chunk = mysqlnd_mempool_resize_chunk; chunk->size = size; /* Should not go over MYSQLND_MAX_PACKET_SIZE, since we expect non-arena memory in mysqlnd_wireprotocol.c . We realloc the non-arena memory. */ - chunk->pool = pool; if (size > pool->free_size) { chunk->from_pool = FALSE; chunk->ptr = mnd_emalloc(size); if (!chunk->ptr) { - chunk->free_chunk(chunk); + pool->free_chunk(pool, chunk); chunk = NULL; } } else { @@ -152,6 +147,8 @@ mysqlnd_mempool_create(size_t arena_size) DBG_ENTER("mysqlnd_mempool_create"); if (ret) { ret->get_chunk = mysqlnd_mempool_get_chunk; + ret->free_chunk = mysqlnd_mempool_free_chunk; + ret->resize_chunk = mysqlnd_mempool_resize_chunk; ret->free_size = ret->arena_size = arena_size ? arena_size : 0; /* OOM ? */ ret->arena = mnd_emalloc(ret->arena_size); -- cgit v1.2.1 From f2ab731a8c47d2988ddf0d61cb06c0f62e17ab19 Mon Sep 17 00:00:00 2001 From: Andrey Hristov Date: Wed, 16 Mar 2016 10:24:52 +0100 Subject: Fix emails in headers. @mysql.com addresses are no more since many years. --- ext/mysqlnd/mysqlnd_block_alloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ext/mysqlnd/mysqlnd_block_alloc.c') diff --git a/ext/mysqlnd/mysqlnd_block_alloc.c b/ext/mysqlnd/mysqlnd_block_alloc.c index 19cc0e41ce..9c5f12130b 100644 --- a/ext/mysqlnd/mysqlnd_block_alloc.c +++ b/ext/mysqlnd/mysqlnd_block_alloc.c @@ -12,9 +12,9 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Georg Richter | - | Andrey Hristov | - | Ulf Wendel | + | Authors: Andrey Hristov | + | Ulf Wendel | + | Georg Richter | +----------------------------------------------------------------------+ */ -- cgit v1.2.1