arthurnn / memcached

A Ruby interface to the libmemcached C client
Academic Free License v3.0
432 stars 127 forks source link

Performance regression going from 1.6 to 1.8 #168

Open StabbyCutyou opened 8 years ago

StabbyCutyou commented 8 years ago

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.

  1. 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.
  2. Is there a way to disable it? Would it be harmful to do so?

Thanks

mikhailov commented 6 years ago

@StabbyCutyou I wonder if you found any workaround for this issue? Thank you!

StabbyCutyou commented 6 years ago

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.