Skip to content

Commit

Permalink
perf: remove unnecessary blocking in EVCacheOperationFuture
Browse files Browse the repository at this point in the history
Currently the EVCacheOperationFuture does an isCancelled check before
emitting a metric, however this metric is now dead code. But, the
isCancelled check is still a synchronized method which results in
occasional blocking against memcache event loop.
  • Loading branch information
jasonk000 committed Jan 27, 2025
1 parent 6c3773d commit ca70c1d
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicReference;

import net.spy.memcached.ops.OperationState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -141,10 +140,10 @@ public EVCacheOperationFuture<T> removeListener(EVCacheGetOperationListener<T> l
* amount of time to wait
* @param units
* unit of time to wait
* @param if
* exeception needs to be thrown of null returned on a failed
* @param throwException
* exception needs to be thrown of null returned on a failed
* operation
* @param has
* @param hasZF
* zone fallback
* @return the operation results of this OperationFuture
* @throws InterruptedException
Expand Down Expand Up @@ -366,13 +365,9 @@ public Single<T> get(long duration, TimeUnit units, boolean throwException, bool
// whenever timeout occurs, continuous timeout counter will increase by 1.
MemcachedConnection.opTimedOut(op);
if (op != null) op.timeOut();
//if (!hasZF) EVCacheMetricsFactory.getCounter(appName, null, serverGroup.getName(), appName + "-get-CheckedOperationTimeout", DataSourceType.COUNTER).increment();
if (throwException) {
subscriber.onError(new CheckedOperationTimeoutException("Timed out waiting for operation", op));
} else {
if (isCancelled()) {
//if (hasZF) EVCacheMetricsFactory.getCounter(appName, null, serverGroup.getName(), appName + "-get-Cancelled", DataSourceType.COUNTER).increment();
}
subscriber.onSuccess(objRef.get());
}
}), scheduler).doAfterTerminate(new Action0() {
Expand Down

0 comments on commit ca70c1d

Please sign in to comment.