summaryrefslogtreecommitdiff
path: root/sql/sql_acl.cc
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 /sql/sql_acl.cc
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 'sql/sql_acl.cc')
-rw-r--r--sql/sql_acl.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 3805d9fa8b6..9a218395721 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -2281,7 +2281,7 @@ GRANT_TABLE::GRANT_TABLE(const char *h, const char *d,const char *u,
const char *t, ulong p, ulong c)
:GRANT_NAME(h,d,u,t,p), cols(c)
{
- (void) hash_init(&hash_columns,system_charset_info,
+ (void) hash_init2(&hash_columns,4,system_charset_info,
0,0,0, (hash_get_key) get_key_column,0,0);
}
@@ -2329,7 +2329,7 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs)
cols= (ulong) form->field[7]->val_int();
cols = fix_rights_for_column(cols);
- (void) hash_init(&hash_columns,system_charset_info,
+ (void) hash_init2(&hash_columns,4,system_charset_info,
0,0,0, (hash_get_key) get_key_column,0,0);
if (cols)
{