This is an automated email from the ASF dual-hosted git repository.
nreich pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 2505155 GEODE-4016: Create benchmarks for eviction (#1240)
2505155 is described below
commit 2505155eaca37043fd7e3ee71ad469704342ce30
Author: Nick Reich <[email protected]>
AuthorDate: Mon Jan 8 15:42:59 2018 -0800
GEODE-4016: Create benchmarks for eviction (#1240)
---
.../cache/benchmark/CreateOnRegionBenchmark.java | 83 +++++++++++++
.../CreateWithEvictionUnderLimitBenchmark.java | 92 ++++++++++++++
.../EvictionBasePerformanceBenchmark.java | 104 ++++++++++++++++
.../EvictionMultiThreadedPerformanceBenchmark.java | 135 +++++++++++++++++++++
.../EvictionWithPartiallyMarkedListsBenchmark.java | 107 ++++++++++++++++
.../cache/benchmark/FirstEvictionBenchmark.java | 86 +++++++++++++
.../cache/benchmark/GetOnRegionBenchmark.java | 85 +++++++++++++
.../GetsWithEvictionPerformanceBenchmark.java | 98 +++++++++++++++
.../cache/benchmark/UpdateOnRegionBenchmark.java | 88 ++++++++++++++
9 files changed, 878 insertions(+)
diff --git
a/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/CreateOnRegionBenchmark.java
b/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/CreateOnRegionBenchmark.java
new file mode 100644
index 0000000..d7e3319
--- /dev/null
+++
b/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/CreateOnRegionBenchmark.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional
information regarding
+ * copyright ownership. The ASF licenses this file to You 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 org.apache.geode.cache.benchmark;
+
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+
+import java.util.concurrent.TimeUnit;
+
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Param;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+import org.openjdk.jmh.annotations.Warmup;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.EvictionAction;
+import org.apache.geode.cache.EvictionAttributes;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.internal.lang.SystemPropertyHelper;
+
+/**
+ * This benchmark measures the raw throughput of create actions on a region
+ */
+@State(Scope.Thread)
+@Fork(1)
+public class CreateOnRegionBenchmark {
+
+ Cache cache;
+ Region<String, String> region;
+
+ @Setup(Level.Trial)
+ public void setup() {
+ cache = new CacheFactory().set(LOG_LEVEL, "warn").create();
+ region = createRegion(cache);
+ }
+
+ @TearDown(Level.Trial)
+ public void tearDown() {
+ cache.close();
+ }
+
+ @State(Scope.Thread)
+ public static class MyState {
+ int nextKey;
+ }
+
+ @Benchmark
+ @Measurement(iterations = 50)
+ @Warmup(iterations = 5)
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ public String createEntry(MyState state) {
+ return region.put(Integer.toString(state.nextKey++), "value");
+ }
+
+ private Region<String, String> createRegion(Cache cache) {
+ Region<String, String> region =
+ cache.<String,
String>createRegionFactory(RegionShortcut.LOCAL).create("testRegion");
+ return region;
+ }
+}
diff --git
a/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/CreateWithEvictionUnderLimitBenchmark.java
b/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/CreateWithEvictionUnderLimitBenchmark.java
new file mode 100644
index 0000000..1be5ac3
--- /dev/null
+++
b/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/CreateWithEvictionUnderLimitBenchmark.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional
information regarding
+ * copyright ownership. The ASF licenses this file to You 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 org.apache.geode.cache.benchmark;
+
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+
+import java.util.concurrent.TimeUnit;
+
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Param;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+import org.openjdk.jmh.annotations.Warmup;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.EvictionAction;
+import org.apache.geode.cache.EvictionAttributes;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.internal.lang.SystemPropertyHelper;
+
+/**
+ * This benchmark measures the raw throughput of create actions on a region
with eviction enabled,
+ * but the region is still under the eviction threshold. Comparison to a
benchmark without eviction
+ * would isolate the overhead of this operation when eviction is enabled.
+ */
+@State(Scope.Thread)
+@Fork(1)
+public class CreateWithEvictionUnderLimitBenchmark {
+ private static final int MAX_ENTRIES = Integer.MAX_VALUE;
+
+ @Param({"true", "false"})
+ public String useAsync;
+
+ Cache cache;
+ Region<String, String> region;
+
+ @Setup(Level.Trial)
+ public void setup() {
+ System.setProperty("geode." + SystemPropertyHelper.EVICTION_SCAN_ASYNC,
useAsync);
+ cache = new CacheFactory().set(LOG_LEVEL, "warn").create();
+ region = createRegion(cache, MAX_ENTRIES);
+ }
+
+ @TearDown(Level.Trial)
+ public void tearDown() {
+ cache.close();
+ }
+
+ @State(Scope.Thread)
+ public static class MyState {
+ int nextKey;
+ }
+
+ @Benchmark
+ @Measurement(iterations = 50)
+ @Warmup(iterations = 5)
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ public String createEntry(MyState state) {
+ return region.put(Integer.toString(state.nextKey++), "value");
+ }
+
+ private Region<String, String> createRegion(Cache cache, int maxSize) {
+ Region<String, String> region = cache.<String,
String>createRegionFactory(RegionShortcut.LOCAL)
+ .setEvictionAttributes(
+ EvictionAttributes.createLRUEntryAttributes(maxSize,
EvictionAction.LOCAL_DESTROY))
+ .create("testRegion");
+ return region;
+ }
+}
diff --git
a/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/EvictionBasePerformanceBenchmark.java
b/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/EvictionBasePerformanceBenchmark.java
new file mode 100644
index 0000000..757edd6
--- /dev/null
+++
b/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/EvictionBasePerformanceBenchmark.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional
information regarding
+ * copyright ownership. The ASF licenses this file to You 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 org.apache.geode.cache.benchmark;
+
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Param;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+import org.openjdk.jmh.annotations.Warmup;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.EvictionAction;
+import org.apache.geode.cache.EvictionAttributes;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.internal.lang.SystemPropertyHelper;
+
+@State(Scope.Thread)
+@Fork(1)
+public class EvictionBasePerformanceBenchmark {
+ private static final int MAX_ENTRIES = 1_000_000;
+
+ @Param({"true", "false"})
+ public String useAsync;
+
+ Cache cache;
+ Region<String, String> region;
+
+ @Setup(Level.Trial)
+ public void setup() {
+ System.setProperty("geode." + SystemPropertyHelper.EVICTION_SCAN_ASYNC,
useAsync);
+ cache = new CacheFactory().set(LOG_LEVEL, "warn").create();
+ region = createRegion(cache, MAX_ENTRIES);
+ }
+
+ @TearDown(Level.Trial)
+ public void tearDown() {
+ cache.close();
+ }
+
+ @State(Scope.Thread)
+ public static class MyState {
+ Random random = new Random();
+ int nextKey = MAX_ENTRIES + 1;
+ }
+
+ @Benchmark
+ @Measurement(iterations = 50)
+ @Warmup(iterations = 5)
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ public String nonEvictingUpdate(MyState state) {
+ String key = Integer.toString(state.random.nextInt(MAX_ENTRIES));
+ return region.put(key, "value");
+ }
+
+ @Benchmark
+ @Measurement(iterations = 50)
+ @Warmup(iterations = 5)
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ public String evictingCreate(MyState state) {
+ String key = Integer.toString(state.nextKey++);
+ return region.put(key, "value");
+ }
+
+ private Region<String, String> createRegion(Cache cache, int maxSize) {
+ Region<String, String> region = cache.<String,
String>createRegionFactory(RegionShortcut.LOCAL)
+ .setEvictionAttributes(
+ EvictionAttributes.createLRUEntryAttributes(maxSize,
EvictionAction.LOCAL_DESTROY))
+ .create("testRegion");
+ for (int i = 0; i < MAX_ENTRIES; i++) {
+ region.put(Integer.toString(i), "value");
+ }
+ region.put("over", "limit");
+ return region;
+ }
+}
diff --git
a/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/EvictionMultiThreadedPerformanceBenchmark.java
b/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/EvictionMultiThreadedPerformanceBenchmark.java
new file mode 100644
index 0000000..9a904fc
--- /dev/null
+++
b/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/EvictionMultiThreadedPerformanceBenchmark.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional
information regarding
+ * copyright ownership. The ASF licenses this file to You 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 org.apache.geode.cache.benchmark;
+
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Param;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+import org.openjdk.jmh.annotations.Threads;
+import org.openjdk.jmh.annotations.Warmup;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.EvictionAction;
+import org.apache.geode.cache.EvictionAttributes;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.internal.lang.SystemPropertyHelper;
+
+@State(Scope.Benchmark)
+@Fork(1)
+public class EvictionMultiThreadedPerformanceBenchmark {
+ private static final int MAX_ENTRIES = 1_000_000;
+
+ @Param({"true", "false"})
+ public String useAsync;
+
+ Cache cache;
+ Region<String, String> region;
+ AtomicInteger nextKey = new AtomicInteger(MAX_ENTRIES + 1);
+
+ @Setup(Level.Trial)
+ public void setup() {
+ System.setProperty("geode." + SystemPropertyHelper.EVICTION_SCAN_ASYNC,
useAsync);
+ cache = new CacheFactory().set(LOG_LEVEL, "warn").create();
+ region = createRegion(cache, MAX_ENTRIES);
+ }
+
+ @TearDown(Level.Trial)
+ public void tearDown() {
+ cache.close();
+ }
+
+ @Benchmark
+ @Measurement(time = 5, iterations = 10)
+ @Warmup(iterations = 5)
+ @BenchmarkMode(Mode.Throughput)
+ @Threads(2)
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ public String evictingCreate1Thread() {
+ String key = Integer.toString(nextKey.incrementAndGet());
+ return region.put(key, "value");
+ }
+
+ @Benchmark
+ @Measurement(time = 5, iterations = 10)
+ @Warmup(iterations = 5)
+ @BenchmarkMode(Mode.Throughput)
+ @Threads(2)
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ public String evictingCreate2Threads() {
+ String key = Integer.toString(nextKey.incrementAndGet());
+ return region.put(key, "value");
+ }
+
+ @Benchmark
+ @Measurement(time = 5, iterations = 10)
+ @Warmup(iterations = 5)
+ @BenchmarkMode(Mode.Throughput)
+ @Threads(4)
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ public String evictingCreate4Threads() {
+ String key = Integer.toString(nextKey.incrementAndGet());
+ return region.put(key, "value");
+ }
+
+ @Benchmark
+ @Measurement(time = 5, iterations = 10)
+ @Warmup(iterations = 5)
+ @BenchmarkMode(Mode.Throughput)
+ @Threads(8)
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ public String evictingCreate8Threads() {
+ String key = Integer.toString(nextKey.incrementAndGet());
+ return region.put(key, "value");
+ }
+
+ @Benchmark
+ @Measurement(time = 5, iterations = 10)
+ @Warmup(iterations = 5)
+ @BenchmarkMode(Mode.Throughput)
+ @Threads(16)
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ public String evictingCreate16Threads() {
+ String key = Integer.toString(nextKey.incrementAndGet());
+ return region.put(key, "value");
+ }
+
+ private Region<String, String> createRegion(Cache cache, int maxSize) {
+ Region<String, String> region = cache.<String,
String>createRegionFactory(RegionShortcut.LOCAL)
+ .setEvictionAttributes(
+ EvictionAttributes.createLRUEntryAttributes(maxSize,
EvictionAction.LOCAL_DESTROY))
+ .create("testRegion");
+ for (int i = 0; i < MAX_ENTRIES; i++) {
+ region.put(Integer.toString(i), "value");
+ }
+ region.put("over", "limit");
+ return region;
+ }
+}
diff --git
a/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/EvictionWithPartiallyMarkedListsBenchmark.java
b/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/EvictionWithPartiallyMarkedListsBenchmark.java
new file mode 100644
index 0000000..43b08ba
--- /dev/null
+++
b/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/EvictionWithPartiallyMarkedListsBenchmark.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional
information regarding
+ * copyright ownership. The ASF licenses this file to You 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 org.apache.geode.cache.benchmark;
+
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Param;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+import org.openjdk.jmh.annotations.Warmup;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.EvictionAction;
+import org.apache.geode.cache.EvictionAttributes;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.internal.lang.SystemPropertyHelper;
+
+@State(Scope.Thread)
+@Fork(1)
+public class EvictionWithPartiallyMarkedListsBenchmark {
+ @Param({"10000", "100000", "1000000"})
+ public int maxEntries;
+
+ @Param({"true", "false"})
+ public String useAsync;
+
+ @Param({"95", "90", "75", "50", "25", "10"})
+ public int markedPercentage;
+
+ Cache cache;
+ Region<String, String> region;
+ List<String> keys = new ArrayList<>();
+ Random random = new Random();
+
+ @Setup(Level.Iteration)
+ public void markEntries() {
+ Collections.shuffle(keys);
+ for (int i = 0; i < maxEntries * (markedPercentage / 100d); i++) {
+ region.get(keys.get(i));
+ }
+ }
+
+ @Setup(Level.Trial)
+ public void setup() {
+ System.setProperty("geode." + SystemPropertyHelper.EVICTION_SCAN_ASYNC,
useAsync);
+ cache = new CacheFactory().set(LOG_LEVEL, "warn").create();
+ region = createRegion(cache, maxEntries);
+ for (int i = 0; i < maxEntries; i++) {
+ keys.add(Integer.toString(i));
+ }
+ }
+
+ @TearDown(Level.Trial)
+ public void tearDown() {
+ cache.close();
+ }
+
+ @Benchmark
+ @Measurement(iterations = 100)
+ @Warmup(iterations = 20)
+ @BenchmarkMode(Mode.SingleShotTime)
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ public String evict() {
+ return region.put("over-limit" + Long.toString(random.nextLong()),
"value");
+ }
+
+ private Region<String, String> createRegion(Cache cache, int maxSize) {
+ Region<String, String> region = cache.<String,
String>createRegionFactory(RegionShortcut.LOCAL)
+ .setEvictionAttributes(
+ EvictionAttributes.createLRUEntryAttributes(maxSize,
EvictionAction.LOCAL_DESTROY))
+ .create("testRegion");
+ for (int i = 0; i < maxEntries; i++) {
+ region.put(Integer.toString(i), "value");
+ }
+ region.put("over-limit", "value");
+ return region;
+ }
+}
diff --git
a/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/FirstEvictionBenchmark.java
b/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/FirstEvictionBenchmark.java
new file mode 100644
index 0000000..37278d6
--- /dev/null
+++
b/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/FirstEvictionBenchmark.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional
information regarding
+ * copyright ownership. The ASF licenses this file to You 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 org.apache.geode.cache.benchmark;
+
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+
+import java.util.concurrent.TimeUnit;
+
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Param;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+import org.openjdk.jmh.annotations.Warmup;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.EvictionAction;
+import org.apache.geode.cache.EvictionAttributes;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.internal.lang.SystemPropertyHelper;
+
+@State(Scope.Thread)
+@Fork(1)
+public class FirstEvictionBenchmark {
+ @Param({"10000", "100000", "1000000"})
+ public int maxEntries;
+
+ @Param({"true", "false"})
+ public String useAsync;
+
+ Cache cache;
+ Region<String, String> region;
+
+ @Setup(Level.Iteration)
+ public void setup() {
+ System.setProperty("geode." + SystemPropertyHelper.EVICTION_SCAN_ASYNC,
useAsync);
+ cache = new CacheFactory().set(LOG_LEVEL, "warn").create();
+ region = createRegion(cache, maxEntries);
+ }
+
+ @TearDown(Level.Iteration)
+ public void tearDown() {
+ cache.close();
+ }
+
+ @Benchmark
+ @Measurement(iterations = 100)
+ @Warmup(iterations = 20)
+ @BenchmarkMode(Mode.SingleShotTime)
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ public String evict() {
+ return region.put("over-limit", "value");
+ }
+
+ private Region<String, String> createRegion(Cache cache, int maxSize) {
+ Region<String, String> region = cache.<String,
String>createRegionFactory(RegionShortcut.LOCAL)
+ .setEvictionAttributes(
+ EvictionAttributes.createLRUEntryAttributes(maxSize,
EvictionAction.LOCAL_DESTROY))
+ .create("testRegion");
+ for (int i = 0; i < maxEntries; i++) {
+ region.put(Integer.toString(i), "value");
+ }
+ return region;
+ }
+}
diff --git
a/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/GetOnRegionBenchmark.java
b/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/GetOnRegionBenchmark.java
new file mode 100644
index 0000000..50eb6f0
--- /dev/null
+++
b/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/GetOnRegionBenchmark.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional
information regarding
+ * copyright ownership. The ASF licenses this file to You 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 org.apache.geode.cache.benchmark;
+
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+import org.openjdk.jmh.annotations.Warmup;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionShortcut;
+
+/**
+ * This benchmark measures the raw throughput of get actions on a region
+ */
+@State(Scope.Thread)
+@Fork(1)
+public class GetOnRegionBenchmark {
+ private static final int ENTRIES = 1_000_000;
+
+ Cache cache;
+ Region<String, String> region;
+
+ @Setup(Level.Trial)
+ public void setup() {
+ cache = new CacheFactory().set(LOG_LEVEL, "warn").create();
+ region = createRegion(cache);
+ }
+
+ @TearDown(Level.Trial)
+ public void tearDown() {
+ cache.close();
+ }
+
+ @State(Scope.Thread)
+ public static class MyState {
+ Random random = new Random();
+ }
+
+ @Benchmark
+ @Measurement(iterations = 50)
+ @Warmup(iterations = 5)
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ public String createEntry(MyState state) {
+ String key = Integer.toString(state.random.nextInt(ENTRIES));
+ return region.get(key);
+ }
+
+ private Region<String, String> createRegion(Cache cache) {
+ Region<String, String> region =
+ cache.<String,
String>createRegionFactory(RegionShortcut.LOCAL).create("testRegion");
+ for (int i = 0; i < ENTRIES; i++) {
+ region.put(Integer.toString(i), "value");
+ }
+ return region;
+ }
+}
diff --git
a/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/GetsWithEvictionPerformanceBenchmark.java
b/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/GetsWithEvictionPerformanceBenchmark.java
new file mode 100644
index 0000000..fb36c81
--- /dev/null
+++
b/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/GetsWithEvictionPerformanceBenchmark.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional
information regarding
+ * copyright ownership. The ASF licenses this file to You 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 org.apache.geode.cache.benchmark;
+
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Param;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+import org.openjdk.jmh.annotations.Warmup;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.EvictionAction;
+import org.apache.geode.cache.EvictionAttributes;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.internal.lang.SystemPropertyHelper;
+
+/**
+ * This benchmark tests the raw throughput of get operations on a region with
eviction enabled. For
+ * each operation, a random key (that exists) is used. Comparison to a
benchmark for a region
+ * without eviction would isolate the overhead of this operation when eviction
is enabled
+ */
+@State(Scope.Thread)
+@Fork(1)
+public class GetsWithEvictionPerformanceBenchmark {
+ private static final int MAX_ENTRIES = 1_000_000;
+
+ @Param({"true", "false"})
+ public String useAsync;
+
+ Cache cache;
+ Region<String, String> region;
+
+ @Setup(Level.Trial)
+ public void setup() {
+ System.setProperty("geode." + SystemPropertyHelper.EVICTION_SCAN_ASYNC,
useAsync);
+ cache = new CacheFactory().set(LOG_LEVEL, "warn").create();
+ region = createRegion(cache, MAX_ENTRIES);
+ }
+
+ @TearDown(Level.Trial)
+ public void tearDown() {
+ cache.close();
+ }
+
+ @State(Scope.Thread)
+ public static class MyState {
+ Random random = new Random();
+ }
+
+ @Benchmark
+ @Measurement(iterations = 10)
+ @Warmup(iterations = 5)
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ public String evictingCreate(MyState state) {
+ String key = Integer.toString(state.random.nextInt(MAX_ENTRIES));
+ return region.get(key);
+ }
+
+ private Region<String, String> createRegion(Cache cache, int maxSize) {
+ Region<String, String> region = cache.<String,
String>createRegionFactory(RegionShortcut.LOCAL)
+ .setEvictionAttributes(
+ EvictionAttributes.createLRUEntryAttributes(maxSize,
EvictionAction.LOCAL_DESTROY))
+ .create("testRegion");
+ for (int i = 0; i < MAX_ENTRIES; i++) {
+ region.put(Integer.toString(i), "value");
+ }
+ region.put("over", "limit");
+ return region;
+ }
+}
diff --git
a/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/UpdateOnRegionBenchmark.java
b/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/UpdateOnRegionBenchmark.java
new file mode 100644
index 0000000..ad4b677
--- /dev/null
+++
b/geode-benchmarks/src/jmh/java/org/apache/geode/cache/benchmark/UpdateOnRegionBenchmark.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional
information regarding
+ * copyright ownership. The ASF licenses this file to You 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 org.apache.geode.cache.benchmark;
+
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Param;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+import org.openjdk.jmh.annotations.Warmup;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.EvictionAction;
+import org.apache.geode.cache.EvictionAttributes;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.internal.lang.SystemPropertyHelper;
+
+@State(Scope.Thread)
+@Fork(1)
+public class UpdateOnRegionBenchmark {
+ private static final int ENTRIES = 1_000_000;
+
+ Cache cache;
+ Region<String, String> region;
+
+ @Setup(Level.Trial)
+ public void setup() {
+ cache = new CacheFactory().set(LOG_LEVEL, "warn").create();
+ region = createRegion(cache, ENTRIES);
+ }
+
+ @TearDown(Level.Trial)
+ public void tearDown() {
+ cache.close();
+ }
+
+ @State(Scope.Thread)
+ public static class MyState {
+ Random random = new Random();
+ }
+
+ @Benchmark
+ @Measurement(iterations = 50)
+ @Warmup(iterations = 5)
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ public String updateRegion(MyState state) {
+ String key = Integer.toString(state.random.nextInt(ENTRIES));
+ return region.put(key, "value");
+ }
+
+ private Region<String, String> createRegion(Cache cache, int maxSize) {
+ Region<String, String> region = cache.<String,
String>createRegionFactory(RegionShortcut.LOCAL)
+ .setEvictionAttributes(
+ EvictionAttributes.createLRUEntryAttributes(maxSize,
EvictionAction.LOCAL_DESTROY))
+ .create("testRegion");
+ for (int i = 0; i < ENTRIES; i++) {
+ region.put(Integer.toString(i), "value");
+ }
+ return region;
+ }
+}
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].