diff options
author | unknown <thek@adventure.(none)> | 2008-03-18 10:45:36 +0100 |
---|---|---|
committer | unknown <thek@adventure.(none)> | 2008-03-18 10:45:36 +0100 |
commit | 001829914befbbaec672334b298d152fa8727060 (patch) | |
tree | 2cb5203bbffd92a37d5e113542f423cd9a2f1438 /mysys/hash.c | |
parent | 269ccba9e782877f65e940cc6a390e6d9686ae1e (diff) | |
download | mariadb-git-001829914befbbaec672334b298d152fa8727060.tar.gz |
Bug#25175 Too much memory used by MySQL grant system
Each time the server reloads privileges containing table grants, the
system will allocate too much memory than needed because of badly
chosen growth prediction in the underlying dynamic arrays.
This patch introduces a new signature to the hash container initializer
which enables a much more pessimistic approach in favour for more
efficient memory useage.
This patch was supplied by Google Inc.
include/hash.h:
* New signature for _hash_init.
* Defined new function hash_init2 which takes growth_size argument.
mysys/hash.c:
* New signature for _hash_init.
sql/sql_acl.cc:
* Changed hash_init signature so that it takes a 'growth_size' smaller
than the default. Each time a GRANT_TABLE is allocated a pre-allocated
dynamic array is instantiated. A large growth size can result in too
many unused hash-entries per table-entry and thus be a waste of free
memory.
Diffstat (limited to 'mysys/hash.c')
-rw-r--r-- | mysys/hash.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/mysys/hash.c b/mysys/hash.c index 4532b06b533..9166ae6f788 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -46,7 +46,7 @@ static uint calc_hash(const HASH *hash, const uchar *key, size_t length) } my_bool -_hash_init(HASH *hash,CHARSET_INFO *charset, +_hash_init(HASH *hash,uint growth_size, CHARSET_INFO *charset, ulong size, size_t key_offset, size_t key_length, hash_get_key get_key, void (*free_element)(void*),uint flags CALLER_INFO_PROTO) @@ -55,7 +55,8 @@ _hash_init(HASH *hash,CHARSET_INFO *charset, DBUG_PRINT("enter",("hash: 0x%lx size: %u", (long) hash, (uint) size)); hash->records=0; - if (my_init_dynamic_array_ci(&hash->array,sizeof(HASH_LINK),size,0)) + if (my_init_dynamic_array_ci(&hash->array, sizeof(HASH_LINK), size, + growth_size)) { hash->free=0; /* Allow call to hash_free */ DBUG_RETURN(1); |