diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2014-03-06 16:19:12 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2014-03-06 16:19:12 +0400 |
commit | b95c8ce530cbbd92b232324dc2c4376615bd1b5d (patch) | |
tree | 60222ef1542c97949e24dcbc4474f5484b86119b /strings | |
parent | ae87e63184a451cd0c9cf95f11f51b78bb40fbc3 (diff) | |
download | mariadb-git-b95c8ce530cbbd92b232324dc2c4376615bd1b5d.tar.gz |
MDEV-5675 - Performance: my_hash_sort_bin is called too often
Reduced number of my_hash_sort_bin() calls from 4 to 1 per query.
Reduced number of memory accesses done by my_hash_sort_bin().
Details:
- let MDL subsystem use pre-calculated hash value for hash
inserts and deletes
- let table cache use pre-calculated MDL hash value
- MDL namespace is excluded from hash value calculation, so that
hash value can be used by table cache as is
- hash value for MDL is calculated as resulting hash value + MDL
namespace
- extended hash implementation to accept user defined hash function
Diffstat (limited to 'strings')
-rw-r--r-- | strings/ctype-bin.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index 71dc78d7593..6e861f38ae4 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -276,7 +276,9 @@ void my_hash_sort_8bit_bin(CHARSET_INFO *cs __attribute__((unused)), const uchar *key, size_t len, ulong *nr1, ulong *nr2) { - + ulong tmp1= *nr1; + ulong tmp2= *nr2; + /* Remove trailing spaces. We have to do this to be able to compare 'A ' and 'A' as identical @@ -285,10 +287,13 @@ void my_hash_sort_8bit_bin(CHARSET_INFO *cs __attribute__((unused)), for (; key < end ; key++) { - nr1[0]^=(ulong) ((((uint) nr1[0] & 63)+nr2[0]) * - ((uint)*key)) + (nr1[0] << 8); - nr2[0]+=3; + tmp1^= (ulong) ((((uint) tmp1 & 63) + tmp2) * + ((uint) *key)) + (tmp1 << 8); + tmp2+= 3; } + + *nr1= tmp1; + *nr2= tmp2; } @@ -296,13 +301,18 @@ void my_hash_sort_bin(CHARSET_INFO *cs __attribute__((unused)), const uchar *key, size_t len,ulong *nr1, ulong *nr2) { const uchar *end = key + len; - + ulong tmp1= *nr1; + ulong tmp2= *nr2; + for (; key < end ; key++) { - nr1[0]^=(ulong) ((((uint) nr1[0] & 63)+nr2[0]) * - ((uint)*key)) + (nr1[0] << 8); - nr2[0]+=3; + tmp1^= (ulong) ((((uint) tmp1 & 63) + tmp2) * + ((uint) *key)) + (tmp1 << 8); + tmp2+= 3; } + + *nr1= tmp1; + *nr2= tmp2; } |