Skip to content

Commit

Permalink
Disable fastpath for hot reads
Browse files Browse the repository at this point in the history
The idea was that the hottest entries don't need to be reordered on
reads, due to already being in a desirable state. Based on the power
law, this would avoid unnecessary work for the majority of reads. When
the hot entries are demoted, due to colder entries being promoted, the
fast path wouldn't apply and it would regain its status. Thus little
impact to the hit rate for faster throughput.

Unfortunately benchmarks show otherwise. The throughput varies wildly
and is always lower. This might be due to some type of thrashing in the
CPU caches, but I'm really not sure. So its turned off but can be enabled
in the future if a solution is found.
  • Loading branch information
ben-manes committed Nov 9, 2015
1 parent 2a8c688 commit 4b73c14
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ private LocalCacheSelectorCode expires() {

private LocalCacheSelectorCode fastpath() {
block.beginControlFlow("if (fastpath)")
.addStatement("sb.append('F')")
.addStatement("// disabled due to unfavorable benchmarks")
.addStatement("// sb.append('F')")
.endControlFlow();
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,9 @@ void afterRead(Node<K, V> node, long now, boolean recordHit) {
}
node.setAccessTime(now);

boolean delayable = canFastpath(node) || (readBuffer.offer(node) != Buffer.FULL);
// fastpath is disabled due to unfavorable benchmarks
// boolean delayable = canFastpath(node) || (readBuffer.offer(node) != Buffer.FULL);
boolean delayable = (readBuffer.offer(node) != Buffer.FULL);
if (shouldDrainBuffers(delayable)) {
scheduleDrainBuffers();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public void exceedsMaximumBufferSize_onWrite(Cache<Integer, Integer> cache) {
assertThat(localCache.writeQueue(), hasSize(0));
}

@Test(dataProvider = "caches")
@Test(enabled = false, dataProvider = "caches")
@CacheSpec(compute = Compute.SYNC, implementation = Implementation.Caffeine,
population = Population.PARTIAL, maximumSize = MaximumSize.FULL,
weigher = {CacheWeigher.DEFAULT, CacheWeigher.TEN},
Expand Down Expand Up @@ -330,7 +330,7 @@ public void fastpath(Cache<Integer, Integer> cache, CacheContext context) {
assertThat(middle.getMoveCount(), is(initialMoveCount + 1));
}

@Test(dataProvider = "caches")
@Test(enabled = false, dataProvider = "caches")
@CacheSpec(compute = Compute.SYNC, implementation = Implementation.Caffeine,
population = Population.FULL, maximumSize = MaximumSize.FULL, weigher = CacheWeigher.DEFAULT,
expireAfterAccess = Expire.DISABLED, expireAfterWrite = Expire.DISABLED,
Expand Down

0 comments on commit 4b73c14

Please sign in to comment.