Skip to content

Instantly share code, notes, and snippets.

View ben-manes's full-sized avatar

Ben Manes ben-manes

View GitHub Profile

All versions of Ehcache 3 suffer from entries clustering which can lead to severely degraded performance and is a potential attack vulnerability (denial of service).

Observation

The performance of the eviction policy reduces as the cache size increases due to the eviction implementation in their customized hash table. On an M3 Max laptop, Ehcache takes over 18 minutes in an IBM SQL database workload trace, whereas Guava and Caffeine take only 15 seconds and 7 seconds respectively. The runtime will be significantly worse on typical, virtualized cloud compute rather than a high performance laptop.

$ git clone https://github.com/ben-manes/caffeine.git
$ pushd caffeine ; git checkout 2fee4bdaff40a76c44cccbdfe954059ed6c3f2bc ; popd
$ wget https://github.com/moka-rs/cache-trace/raw/ef0a9de8cf0202a1f2fee186a0af497774b0f0a9/arc/DS1.lis.zst
$ ./caffeine/gradlew --project-dir caffeine simulator:run -q \
[
{
"jmhVersion" : "1.37",
"benchmark" : "com.github.benmanes.caffeine.cache.EvictionBenchmark.evict",
"mode" : "thrpt",
"threads" : 1,
"forks" : 1,
"jvm" : "/usr/lib/jvm/temurin-21-jdk-amd64/bin/java",
"jvmArgs" : [
"-Xmx4g"
@ben-manes
ben-manes / timerwheel_results_dragonwell_21.json
Last active April 20, 2025 17:15
TimerWheel JMH Results
[
{
"jmhVersion" : "1.37",
"benchmark" : "com.github.benmanes.caffeine.cache.TimerWheelBenchmark.ascending",
"mode" : "thrpt",
"threads" : 1,
"forks" : 1,
"jvm" : "/usr/lib/jvm/temurin-21-jdk-amd64/bin/java",
"jvmArgs" : [
"-Xmx4g"
@ben-manes
ben-manes / freq_results_dragonwell_21.json
Last active April 20, 2025 17:33
FrequencySketch JMH Results
[
{
"jmhVersion" : "1.37",
"benchmark" : "com.github.benmanes.caffeine.cache.FrequencySketchBenchmark.frequency",
"mode" : "thrpt",
"threads" : 1,
"forks" : 1,
"jvm" : "/usr/lib/jvm/temurin-21-jdk-amd64/bin/java",
"jvmArgs" : [
"-Xmx4g"
@ben-manes
ben-manes / putremove_results_dragonwell_21.json
Last active April 20, 2025 17:12
Put/Remove JMH Results
[
{
"jmhVersion" : "1.37",
"benchmark" : "com.github.benmanes.caffeine.cache.PutRemoveBenchmark.group",
"mode" : "thrpt",
"threads" : 8,
"forks" : 1,
"jvm" : "/usr/lib/jvm/temurin-21-jdk-amd64/bin/java",
"jvmArgs" : [
"-Xmx4g"
[
{
"jmhVersion" : "1.37",
"benchmark" : "com.github.benmanes.caffeine.cache.ComputeBenchmark.compute_sameKey",
"mode" : "thrpt",
"threads" : 32,
"forks" : 1,
"jvm" : "/usr/lib/jvm/temurin-21-jdk-amd64/bin/java",
"jvmArgs" : [
"-Xmx4g"
@ben-manes
ben-manes / getput_results_dragonwell_21.json
Last active April 20, 2025 17:16
Get/Put JMH Results
[
{
"jmhVersion" : "1.37",
"benchmark" : "com.github.benmanes.caffeine.cache.GetPutBenchmark.read_only",
"mode" : "thrpt",
"threads" : 8,
"forks" : 1,
"jvm" : "/usr/lib/jvm/temurin-21-jdk-amd64/bin/java",
"jvmArgs" : [
"-Xmx4g"
@ben-manes
ben-manes / caffeine-cla.md
Created October 11, 2020 09:13
Caffeine CLA

Caffeine's CLA is directly based on the Apache Software Foundation's, where "Foundation" is replaced with "Caffeine project". Please see their website regarding any questions, https://www.apache.org/licenses/contributor-agreements.html


Thank you for your interest in the Caffeine project. In order to clarify the intellectual property license granted with Contributions from any person or entity, the Caffeine project must have a Contributor License Agreement ("CLA") on file that has been signed by each Contributor, indicating agreement to the license terms below. This license is for your protection as a Contributor as well as the protection of the Caffeine project and its users; it does not change your rights to use your own Contributions for any other purpose. If you have not already done so, please complete and sign this Agreement. Please read this document carefully before signing and keep a copy for your records.

You accept and agree to the following terms and conditions for Your present and future Co

/* Copyright 2016 LoadDocs */
package co.loaddocs.service.document.upload;
import static org.bytedeco.javacpp.opencv_core.CV_32F;
import static org.bytedeco.javacpp.opencv_imgcodecs.IMREAD_GRAYSCALE;
import static org.bytedeco.javacpp.opencv_imgcodecs.cvLoadImage;
import static org.bytedeco.javacpp.opencv_imgcodecs.imread;
import static org.bytedeco.javacpp.opencv_imgcodecs.imwrite;
import static org.bytedeco.javacpp.opencv_imgproc.warpPerspective;
@ben-manes
ben-manes / Stresser.java
Last active December 8, 2019 00:32
Stresser
import static java.util.concurrent.TimeUnit.SECONDS;
import java.time.LocalTime;
import java.util.Arrays;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import com.google.common.cache.Cache;