memcached
memcached copied to clipboard
Performance regression going from 1.6 to 1.8
Hello,
We're updating the memcached gem as we're fairly out of date at this point, and noticed in some particularly hot areas of code, we're now seeing what looks like double the amount of network hops to our memcached cluster, as well as overall 2x to 3x more time spent in memcached code.
I tracked down the differences in the code between the two versions, and found this:
Original code (1.6.x): https://github.com/arthurnn/memcached/blob/memcached-1.6.1/lib/memcached/memcached.rb#L519-L524
New code (1.8): https://github.com/arthurnn/memcached/blob/f9d4d78156fea4011a291d383a959e9435427515/lib/memcached/memcached.rb#L671-L677
It seems there was a compare and swap call added to every single-item lookup, if you have cas enabled. We do use cas in some places with our memcached client, but those are explicit calls to compare and swap. It seems odd that just because we want to use cas in some place, it's now being used in others as well.
- Would the constant calls to cas be responsible for the performance regression? It seems as though it would account for the 2x hits to memcache itself, as well as the extra time spent in memcached code.
- Is there a way to disable it? Would it be harmful to do so?
Thanks
@StabbyCutyou I wonder if you found any workaround for this issue? Thank you!
I no longer work for the company where we were having this issue, sorry! I don't believe we ever found a workaround, we just ate the cost and moved on, iirc.