summaryrefslogtreecommitdiff
path: root/include/hash.h
diff options
context:
space:
mode:
authorunknown <thek@adventure.(none)>2008-03-18 10:45:36 +0100
committerunknown <thek@adventure.(none)>2008-03-18 10:45:36 +0100
commit001829914befbbaec672334b298d152fa8727060 (patch)
tree2cb5203bbffd92a37d5e113542f423cd9a2f1438 /include/hash.h
parent269ccba9e782877f65e940cc6a390e6d9686ae1e (diff)
downloadmariadb-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 'include/hash.h')
-rw-r--r--include/hash.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/include/hash.h b/include/hash.h
index d924e62a0ec..4ca8dc0e8bf 100644
--- a/include/hash.h
+++ b/include/hash.h
@@ -47,8 +47,9 @@ typedef struct st_hash {
/* A search iterator state */
typedef uint HASH_SEARCH_STATE;
-#define hash_init(A,B,C,D,E,F,G,H) _hash_init(A,B,C,D,E,F,G, H CALLER_INFO)
-my_bool _hash_init(HASH *hash, CHARSET_INFO *charset,
+#define hash_init(A,B,C,D,E,F,G,H) _hash_init(A,0,B,C,D,E,F,G,H CALLER_INFO)
+#define hash_init2(A,B,C,D,E,F,G,H,I) _hash_init(A,B,C,D,E,F,G,H,I CALLER_INFO)
+my_bool _hash_init(HASH *hash, uint growth_size,CHARSET_INFO *charset,
ulong default_array_elements, size_t key_offset,
size_t key_length, hash_get_key get_key,
void (*free_element)(void*), uint flags CALLER_INFO_PROTO);
@@ -69,7 +70,7 @@ my_bool hash_check(HASH *hash); /* Only in debug library */
#define hash_clear(H) bzero((char*) (H),sizeof(*(H)))
#define hash_inited(H) ((H)->array.buffer != 0)
#define hash_init_opt(A,B,C,D,E,F,G,H) \
- (!hash_inited(A) && _hash_init(A,B,C,D,E,F,G, H CALLER_INFO))
+ (!hash_inited(A) && _hash_init(A,0,B,C,D,E,F,G, H CALLER_INFO))
#ifdef __cplusplus
}