These are more or less expected timings. The slow part is the
serialization on the server (if you were using a real client,
serialization on the client would make this take longer) and
transferring the data itself.
> ./redis-benchmark -n 100 smembers set # about 10ms
> ====== smembers set ======
> 100 requests completed in 0.93 seconds
Also expected timings. It doesn't need to serialize scores, which is
why it is over 2x faster.
> /redis-benchmark -n 100 zinterstore zset2 2 set zset # about 75ms
> ====== zinterstore zset2 2 set zset ======
> 100 requests completed in 7.44 seconds
I get closer to 20-25ms on a 2.4 ghz core 2 duo running this one from
a regular client, and ~27ms on average when running with
redis-benchmark. The 20-25 ms is what I would consider to be expected
(the 27 ms is what I would expect when repeatedly writing to the same
key, as that key needs to be deleted before it is replaced), maybe a
little less when running on a machine with a faster processor and/or
lower-latency memory.
> For comparison, doing the same operation in Scala appears to take
> about 20ms:
>
> val set: Set[Long] = Set() ++ {0L to 25000L}
> val zset: collection.SortedMap[Long, Double] = new
> collection.immutable.TreeMap[Long, Double]() ++ (0L to 25000L).map { k
> => k -> k.toDouble }
> var rv = System.currentTimeMillis; for(i <- 0 to 100) { zset.filter
> { case (k, _) => set.contains(k) } }; rv = (System.currentTimeMillis -
> rv) / 100
> rv: Long = 21
>
> Maybe I'm not comparing apples to apples here? Otherwise, something
> seems off.
Intersections in Redis are not as fast as can be attained in other
software or languages. This has to do with the structures and memory
access patterns. Aside from the ~75ms intersection which seems to be
roughly 3x what you should be seeing, all of your timings are not
unreasonable given your hardware and Redis. You have to decide whether
Redis will be fast enough for your needs, given your requirements.
Regards,
- Josiah