-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stronger protection against excess scheduling [ci skip]
A quick experiment showing that perfect scheduling has an insignificant effect. The tryLock trick already avoids almost all duplicates due to writer stampedes during the scheduling window. Unless the executor is clogged there shouldn't be an impact and benchmarks didn't have any conclusive difference. The perfect state machine is only slightly more expensive to maintain. So this remains as a brain dump for revisiting in case the issue raised by user incident.
- Loading branch information
Showing
2 changed files
with
46 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,10 +21,7 @@ | |
import java.util.Arrays; | ||
import java.util.concurrent.Executors; | ||
import java.util.concurrent.ForkJoinPool; | ||
<<<<<<< edee8ed34ba79b4b021beb49d4094eb411eaf317 | ||
import java.util.concurrent.ThreadFactory; | ||
======= | ||
>>>>>>> More graceful executor error handling for removal notifications | ||
import java.util.concurrent.ThreadLocalRandom; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.atomic.LongAdder; | ||
|
@@ -33,10 +30,7 @@ | |
|
||
import com.github.benmanes.caffeine.testing.ConcurrentTestHarness; | ||
import com.google.common.base.Stopwatch; | ||
<<<<<<< edee8ed34ba79b4b021beb49d4094eb411eaf317 | ||
import com.google.common.util.concurrent.ThreadFactoryBuilder; | ||
======= | ||
>>>>>>> More graceful executor error handling for removal notifications | ||
|
||
/** | ||
* A stress test to observe if the cache has a memory leak by not being able to drain the buffers | ||
|
@@ -45,7 +39,8 @@ | |
* @author [email protected] (Ben Manes) | ||
*/ | ||
public final class Stresser { | ||
private static final String[] STATUS = { "Idle", "Required", "Processing" }; | ||
private static final String[] STATUS = | ||
{ "Idle", "Required", "Processing -> Idle", "Processing -> Required" }; | ||
private static final int THREADS = 2 * Runtime.getRuntime().availableProcessors(); | ||
private static final int WRITE_MAX_SIZE = (1 << 12); | ||
private static final int TOTAL_KEYS = (1 << 20); | ||
|
@@ -62,15 +57,11 @@ public final class Stresser { | |
private final boolean reads = true; | ||
|
||
public Stresser() { | ||
<<<<<<< edee8ed34ba79b4b021beb49d4094eb411eaf317 | ||
ThreadFactory threadFactory = new ThreadFactoryBuilder() | ||
.setPriority(Thread.MAX_PRIORITY) | ||
.setDaemon(true) | ||
.build(); | ||
Executors.newSingleThreadScheduledExecutor(threadFactory) | ||
======= | ||
Executors.newSingleThreadScheduledExecutor() | ||
>>>>>>> More graceful executor error handling for removal notifications | ||
.scheduleAtFixedRate(this::status, STATUS_INTERVAL, STATUS_INTERVAL, SECONDS); | ||
maximum = reads ? TOTAL_KEYS : WRITE_MAX_SIZE; | ||
evictions = new LongAdder(); | ||
|