diff --git a/gradle/config/spotbugs/exclude.xml b/gradle/config/spotbugs/exclude.xml index 40c38c4fe5..c512991bff 100644 --- a/gradle/config/spotbugs/exclude.xml +++ b/gradle/config/spotbugs/exclude.xml @@ -8,6 +8,7 @@ ACEM_ABSTRACT_CLASS_EMPTY_METHODS, AI_ANNOTATION_ISSUES_NEEDS_NULLABLE, AOM_ABSTRACT_OVERRIDDEN_METHOD, + BAS_BLOATED_ASSIGNMENT_SCOPE, BL_BURYING_LOGIC, CE_CLASS_ENVY, CFS_CONFUSING_FUNCTION_SEMANTICS, diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9fbf397f6d..2e8a6d9da1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -19,7 +19,7 @@ commons-text = "1.11.0" concurrentlinkedhashmap = "1.4.2" config = "1.4.3" coveralls = "2.12.2" -dependency-check = "9.0.0" +dependency-check = "9.0.1" eclipse-collections = "12.0.0.M3" ehcache3 = "3.10.8" errorprone-core = "2.23.0" @@ -81,7 +81,7 @@ slf4j = "2.0.9" slf4j-test = "3.0.1" snakeyaml = "2.2" sonarqube = "4.4.1.3373" -spotbugs-contrib = "7.6.0" +spotbugs-contrib = "7.6.1" spotbugs-core = "4.8.1" spotbugs-plugin = "6.0.0-rc.2" stream = "2.9.8" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 27c20c219b..11ed895659 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,4 +1,4 @@ -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-rc-3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-rc-4-bin.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/simulator/build.gradle.kts b/simulator/build.gradle.kts index 2b43da6783..2c5baecdd2 100644 --- a/simulator/build.gradle.kts +++ b/simulator/build.gradle.kts @@ -14,7 +14,6 @@ dependencies { implementation(project(":caffeine")) implementation(libs.xz) - implementation(libs.ohc) implementation(libs.ycsb) { isTransitive = false } diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/Registry.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/Registry.java index 8ea052b47b..ebe32aef98 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/Registry.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/Registry.java @@ -58,7 +58,6 @@ import com.github.benmanes.caffeine.cache.simulator.policy.product.ExpiringMapPolicy; import com.github.benmanes.caffeine.cache.simulator.policy.product.GuavaPolicy; import com.github.benmanes.caffeine.cache.simulator.policy.product.HazelcastPolicy; -import com.github.benmanes.caffeine.cache.simulator.policy.product.OhcPolicy; import com.github.benmanes.caffeine.cache.simulator.policy.product.TCachePolicy; import com.github.benmanes.caffeine.cache.simulator.policy.sampled.SampledPolicy; import com.github.benmanes.caffeine.cache.simulator.policy.sketch.WindowTinyLfuPolicy; @@ -223,7 +222,6 @@ private void registerGreedyDual() { private void registerProduct() { register(GuavaPolicy.class, GuavaPolicy::new); register(Cache2kPolicy.class, Cache2kPolicy::new); - registerMany(OhcPolicy.class, OhcPolicy::policies); register(CaffeinePolicy.class, CaffeinePolicy::new); register(Ehcache3Policy.class, Ehcache3Policy::new); registerMany(TCachePolicy.class, TCachePolicy::policies); diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/OhcPolicy.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/OhcPolicy.java deleted file mode 100644 index 5c3e897c24..0000000000 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/OhcPolicy.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2016 Ben Manes. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.github.benmanes.caffeine.cache.simulator.policy.product; - -import static com.google.common.base.Preconditions.checkState; -import static java.util.Locale.US; -import static java.util.stream.Collectors.toUnmodifiableSet; - -import java.io.IOException; -import java.io.UncheckedIOException; -import java.nio.ByteBuffer; -import java.util.EnumSet; -import java.util.Set; - -import org.caffinitas.ohc.CacheSerializer; -import org.caffinitas.ohc.Eviction; -import org.caffinitas.ohc.OHCache; -import org.caffinitas.ohc.OHCacheBuilder; - -import com.github.benmanes.caffeine.cache.simulator.BasicSettings; -import com.github.benmanes.caffeine.cache.simulator.policy.Policy; -import com.github.benmanes.caffeine.cache.simulator.policy.Policy.KeyOnlyPolicy; -import com.github.benmanes.caffeine.cache.simulator.policy.Policy.PolicySpec; -import com.github.benmanes.caffeine.cache.simulator.policy.PolicyStats; -import com.typesafe.config.Config; - -/** - * Off-Heap-Cache implementation. - * - * @author ben.manes@gmail.com (Ben Manes) - */ -@PolicySpec(name = "product.OHC") -public final class OhcPolicy implements KeyOnlyPolicy { - private static final long ENTRY_SIZE = 80; - - private final OHCache cache; - private final PolicyStats policyStats; - - public OhcPolicy(OhcSettings settings, Eviction policy) { - policyStats = new PolicyStats(name() + " (%s)", (policy == Eviction.LRU) ? "Lru" : "W-TinyLfu"); - cache = OHCacheBuilder.newBuilder() - .capacity(ENTRY_SIZE * settings.maximumSize()) - .valueSerializer(LongSerializer.INSTANCE) - .keySerializer(LongSerializer.INSTANCE) - .edenSize(settings.percentEden()) - .eviction(policy) - .build(); - } - - /** Returns all variations of this policy based on the configuration parameters. */ - public static Set policies(Config config) { - OhcSettings settings = new OhcSettings(config); - return settings.policy().stream() - .map(policy -> new OhcPolicy(settings, policy)) - .collect(toUnmodifiableSet()); - } - - @Override - public void record(long key) { - Object value = cache.get(key); - if (value == null) { - cache.put(key, key); - policyStats.recordMiss(); - } else { - policyStats.recordHit(); - } - } - - @Override - public PolicyStats stats() { - return policyStats; - } - - @Override - public void finished() { - policyStats.addEvictions(cache.stats().getEvictionCount()); - checkState(policyStats.hitCount() == cache.stats().getHitCount()); - checkState(policyStats.missCount() == cache.stats().getMissCount()); - - try { - cache.close(); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - - static final class OhcSettings extends BasicSettings { - public OhcSettings(Config config) { - super(config); - } - public double percentEden() { - return config().getDouble("ohc.percent-eden"); - } - public Set policy() { - var policies = EnumSet.noneOf(Eviction.class); - for (var policy : config().getStringList("ohc.policy")) { - var name = policy.toLowerCase(US).replaceAll("[^a-z]", ""); - if (name.equals("lru")) { - policies.add(Eviction.LRU); - } else if (name.equals("wtinylfu")) { - policies.add(Eviction.W_TINY_LFU); - } else { - throw new IllegalArgumentException("Unknown policy: " + policy); - } - } - return policies; - } - } - - static final class LongSerializer implements CacheSerializer { - static final LongSerializer INSTANCE = new LongSerializer(); - - @Override public void serialize(Long value, ByteBuffer buffer) { - buffer.putLong(value); - } - @Override public Long deserialize(ByteBuffer buffer) { - return buffer.getLong(); - } - @Override public int serializedSize(Long value) { - return Long.BYTES; - } - } -} diff --git a/simulator/src/main/resources/reference.conf b/simulator/src/main/resources/reference.conf index 201d7cb851..4a6bf540f6 100644 --- a/simulator/src/main/resources/reference.conf +++ b/simulator/src/main/resources/reference.conf @@ -98,7 +98,6 @@ caffeine.simulator { adaptive.Cart, # Caching products - product.OHC, product.Guava, product.TCache, product.Cache2k, @@ -451,13 +450,6 @@ caffeine.simulator { policy = [ lru ] } - ohc { - # Policies: Lru, W-TinyLfu - policy = [lru, w-tinylfu] - # The percentage for the EDEN space (admission window) - percent-eden = 0.20 - } - tcache { # Policies: Lru, Lfu policy = [ lru, lfu ]