Apologies for the cross-post from StackOverflow, but I figured I'd get a faster response here than there. I don't believe that redis caches the results of commands, correct? If so, then why would I see the following on my redis server for the same query. For reference, this is redis running in a VM. I checked the smaps file as described in http://redis.io/topics/latency and see no swapping on the OS level (all 0kb in Swap for the process), but is it possible that running redis in a VM pages memory to disk and back? Or... are these results expected due to some kind of redis optimization for commonly run commands?
redis 127.0.0.1:6379[4]> sinterstore testdb ClientId:1637 PublisherId:1 (integer) 240001 (4.46s) redis 127.0.0.1:6379[4]> sinterstore testdb ClientId:1637 PublisherId:1 (integer) 240001 (3.77s) redis 127.0.0.1:6379[4]> sinterstore testdb ClientId:1637 PublisherId:1 (integer) 240001 (0.92s) redis 127.0.0.1:6379[4]> sinterstore testdb ClientId:1637 PublisherId:1 (integer) 240001 (0.64s) redis 127.0.0.1:6379[4]> sinterstore testdb ClientId:1637 PublisherId:1 (integer) 240001 (0.67s) redis 127.0.0.1:6379[4]> sinterstore testdb ClientId:1637 PublisherId:1 (integer) 240001 (0.73s) redis 127.0.0.1:6379[4]> scard ClientId:1637 (integer) 796529 redis 127.0.0.1:6379[4]> scard PublisherId:1 (integer) 311092 redis 127.0.0.1:6379[4]> sinterstore testdb ClientId:1637 PublisherId:1 (integer) 240001 (1.88s) redis 127.0.0.1:6379[4]> sinterstore testdb ClientId:1637 PublisherId:1 (integer) 240001 (0.69s)
To view this discussion on the web visit https://groups.google.com/d/msg/redis-db/-/nfnjiPZcCoYJ.--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To post to this group, send email to redi...@googlegroups.com.
To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
Your answer is closer than you think. My answers below are educated guesses founded on knowledge and experience of equivalent behavior in other systems.CPU caching, branch prediction, memory allocator structure caching, and a variety of other interesting interactions, combined with other processes getting the core are probably what the OP is seeing.When the sinterstore occurs the first time, the cache is "cold" for reading the data and for allocating the structures necessary to support the subsequent result set. The second time, reading is as cached as it can be, but all of the allocations still need to happen on potentially unused structures. But when the key is overwritten at the end of the second sinterstore, the first result is 'freed', but important pieces of the structures involved for the memory allocator that held that data have just been put into cache as part of the freeing process. Then the 3rd time, allocations are traversing many of the previously-cached memory allocation structures, combined with being able to read the somewhat-cached data better, etc.The behavior the OP is seeing when they do something else after the 6th sinterstore is likely the result of letting the caches get cold as the processor, VM, and other layers do other things to dirty the cache, reduce the VM/Redis server process priority, etc.Regards,- Josiah
--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To post to this group, send email to redi...@googlegroups.com.
To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.