performance improvement for jedis cluster info cache #3372
Replies: 5 comments 5 replies
-
`package cluster; import java.util.HashMap; public class TestMap {
// M: 641995fea69ee31d24fbcfec741046255c551f71 127.0.0.1:7379
}` |
Beta Was this translation helpful? Give feedback.
-
hashmap: {size:16384,use:812} vs treemap: {size:3,use:2593} |
Beta Was this translation helpful? Give feedback.
-
@yangbodong22011 @sazzad16 compare with hashmap, treemap aslo arrays. |
Beta Was this translation helpful? Give feedback.
-
@sazzad16 since arrays took 0 seconds . i make same measured data: Reduce 7s for every 10w pieces of data 10w records, use pipelined (arrays cache) to get/set, reduce:7344ms This optimization is included in #3373 , please take a code review , and i wonder this could be merge in next stable 4.x version . thanks. ^_^ |
Beta Was this translation helpful? Give feedback.
-
PR has been merged, closed by #3373 |
Beta Was this translation helpful? Give feedback.
-
@yangbodong22011 @sazzad16
i notice that our cache for slots pool slotsnode use hashmap.
https://github.com/redis/jedis/blob/master/src/main/java/redis/clients/jedis/JedisClusterInfoCache.java#:~:text=public%20class%20JedisClusterInfoCache%20%7B,slotNodes%20%3D%20new%20HashMap%3C%3E()%3B
since slots numbers 16384, so the size of slots /slotNodes should be 16384;
for exampe : redis cluster got 3 nodes:
// M: 641995fea69ee31d24fbcfec741046255c551f71 127.0.0.1:7379
// slots:[0-5460] (5461 slots) master
// M: acab2c371826441e0927e2389785b5a213564d15 127.0.0.1:7380
// slots:[5461-10922] (5462 slots) master
// M: d72cddef3553ec6ee70b81fabb3b0179cb8b9ccc 127.0.0.1:7381
// slots:[10923-16383] (5461 slots) master
the structure for slotNodes size will be 16384, mapping ship like :
{0=127.0.0.1:7379, 1=127.0.0.1:7379, 2=127.0.0.1:7379, 3=127.0.0.1:7379 ........ 16382=127.0.0.1:7381, 16383=127.0.0.1:7381}
since all slots present as number, so [0, 1,2,3,4,5.....5460] , can be mapduce to [0~5460] , after mapreduce
the structure for slotNodes size will be 3
{0=127.0.0.1:7379, 5461=127.0.0.1:7380, 10923=127.0.0.1:7381}
mappingship switch to
{
0
5460:127.0.0.1:7379,10922:127.0.0.1:7380,5461
10923~16383:127.0.0.1:7381,
}
: seems better. In theory, there is an improvement in performance。
i mapreduce to 3 keys, use treemap(lowerkey, talMap.firstKey) . but compare with hashmap: Search efficiency
but, In practice Very strange, Completely wrong !!!!
hashmap(16384keys)seemsbetter than treemap(>3keys).lowerkey for treemap use tree structure. (slower than hashmap structure)
is there any best Practices?
Beta Was this translation helpful? Give feedback.
All reactions