diff options
author | Kamil Cudnik <kcudnik@gmail.com> | 2021-09-09 11:47:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-09 12:47:26 +0300 |
commit | 7f88923b40cf3d7730ab3e1843d42afc58840cb3 (patch) | |
tree | ebdf8fdc4640c5b803910cf5caad633690ae9e8b | |
parent | c50af0aeba693bf93e5c471cff08d8ccde0f5213 (diff) | |
download | redis-7f88923b40cf3d7730ab3e1843d42afc58840cb3.tar.gz |
Lua: Use all characters to calculate string hash (#9449)
For a lot of long strings which have same prefix which extends beyond
hashing limit, there will be many hash collisions which result in
performance degradation using commands like KEYS
-rw-r--r-- | deps/lua/src/lstring.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/deps/lua/src/lstring.c b/deps/lua/src/lstring.c index 49113151c..6a825f786 100644 --- a/deps/lua/src/lstring.c +++ b/deps/lua/src/lstring.c @@ -75,7 +75,7 @@ static TString *newlstr (lua_State *L, const char *str, size_t l, TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { GCObject *o; unsigned int h = cast(unsigned int, l); /* seed */ - size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */ + size_t step = 1; size_t l1; for (l1=l; l1>=step; l1-=step) /* compute hash */ h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1])); |