3 ms·
Why use clear text numbers? Most of the time, you're going to be using large numbers, so binary pack them as save more space. i had the same issue, normal sto
by pedigree 15y ago
Why use clear text numbers? Most of the time, you're going to be using large numbers, so binary pack them as save more space.
i had the same issue, normal storage was 1.1gb of space, HSET down to 200mb and binary packing every integer down dbl() bought it right down to 163mb of memory (32bit instance). For that 163mb, I was slicing a md5 of the field for the hset prefix, packing that and then using the remainer as the hset suffix. (due to the data format of the input field)
- eurleif 15y agoInternally, redis stores integers as 64-bit binary values, not strings: http://redis.io/commands/incr http://redis.io/commands/incr.
- LeafStorm 15y agoI don't think it does that for keys and values in hashes though. The only int-related optimization it does in the collections is integer sets.
- nknight 15y agoRedis is a series of tradeoffs between simplicity, performance, and power. For the moment, simplicity won as far as keys go -- they're all strings, period, end of story. Supporting other key types is potentially useful, but brings complications, some of which will be visible to users of Redis. Your own measurements are telling. Your memory usage went down by about 82%, packing the integers brought that to a bit less than 86%. It's easy to justify a small increase in complexity to save 82%, it's a lot harder to justify even more complexity to bring that number to 86%.
- ctoestreich 15y agoI would like to see some example code or a gist of what you did. I played around with custom number packing and using the hashset in redis inspired by the original thread topic and your comment. You can find the post here: http://www.christianoestreich.com/2011/11/redis-hashsets-performance/ http://www.christianoestreich.com/2011/11/redis-hashsets-per...