This is an automated email from the ASF dual-hosted git repository. mmuzaf pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push: new 6225222 IGNITE-13034: Additional yardstick test for page replacements test (#7828) 6225222 is described below commit 6225222effcd901400bb0a9df26a565dcd33f563 Author: Evgeniy Stanilovskiy <stanilov...@gmail.com> AuthorDate: Thu May 21 19:35:45 2020 +0300 IGNITE-13034: Additional yardstick test for page replacements test (#7828) --- modules/yardstick/README.txt | 1 + .../benchmark-cache-pegereplacements.properties | 83 ++++++++++ .../config/ignite-localhost-persistence-config.xml | 15 +- .../cache/IgnitePutGetWithPageReplacements.java | 172 +++++++++++++++++++++ 4 files changed, 267 insertions(+), 4 deletions(-) diff --git a/modules/yardstick/README.txt b/modules/yardstick/README.txt index 71ed387..45ff48d 100644 --- a/modules/yardstick/README.txt +++ b/modules/yardstick/README.txt @@ -102,6 +102,7 @@ The following benchmarks are provided: 22. `SqlQueryPutOffHeapBenchmark` - benchmarks distributed SQL query with simultaneous cache updates off heap 23. `PutAllBenchmark` - benchmarks atomic distributed cache batch put operation 24. `PutAllTxBenchmark` - benchmarks transactional distributed cache batch put operation +25. `IgnitePutGetWithPageReplacements` - benchmarks atomic cache put with active page replacement. Properties And Command Line Arguments diff --git a/modules/yardstick/config/benchmark-cache-pegereplacements.properties b/modules/yardstick/config/benchmark-cache-pegereplacements.properties new file mode 100644 index 0000000..1da456c --- /dev/null +++ b/modules/yardstick/config/benchmark-cache-pegereplacements.properties @@ -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. + +now0=`date +'%H%M%S'` + +# JVM options. +JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false" + +# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses. +JVM_OPTS=${JVM_OPTS}" \ +-Xloggc:./gc${now0}.log \ +-XX:+PrintGCDetails \ +-verbose:gc \ +-XX:+UseG1GC \ +-XX:+PrintGCDateStamps \ +" + +DRIVER_JVM_OPTS=${DRIVER_JVM_OPTS}"-Xmx1024m" + +SERVER_JVM_OPTS=${SERVER_JVM_OPTS}"-Xms8g -Xmx8g" + +#Ignite version +ver="RELEASE-" + +# List of default probes. +# Add DStatProbe or VmStatProbe if your OS supports it (e.g. if running on Linux). +BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe,DStatProbe + +# Packages where the specified benchmark is searched by reflection mechanism. +BENCHMARK_PACKAGES=org.yardstickframework,org.apache.ignite.yardstick + +# Flag which indicates to restart the servers before every benchmark execution. +RESTART_SERVERS=true + +# Probe point writer class name. +# BENCHMARK_WRITER= + +# The benchmark is applicable only for 1 server and 1 driver +SERVER_HOSTS=127.0.0.1 +DRIVER_HOSTS=127.0.0.1 + +# Remote username. +# REMOTE_USER= + +# Number of nodes, used to wait for the specified number of nodes to start. +nodesNum=$((`echo ${SERVER_HOSTS} | tr ',' '\n' | wc -l` + `echo ${DRIVER_HOSTS} | tr ',' '\n' | wc -l`)) + +# Backups count. +b=0 + +# Warmup. +w=30 + +# Duration. +d=200 + +# Threads count. +t=4 + +# Sync mode. +sm=PRIMARY_SYNC + +# Jobs. +j=10 + +# Run configuration which contains all benchmarks. +# Note that each benchmark is set to run for 300 seconds (5 min) with warm-up set to 60 seconds (1 minute). +CONFIGS="\ +-cfg ${SCRIPT_DIR}/../config/ignite-localhost-persistence-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutGetWithPageReplacements -sn IgniteNode -ds ${ver}cache-pagereplacement-r1-${b}-backup -cl,\ +" diff --git a/modules/yardstick/config/ignite-localhost-persistence-config.xml b/modules/yardstick/config/ignite-localhost-persistence-config.xml index 2e9d9ff..0ecabd1 100644 --- a/modules/yardstick/config/ignite-localhost-persistence-config.xml +++ b/modules/yardstick/config/ignite-localhost-persistence-config.xml @@ -21,14 +21,20 @@ Ignite Spring configuration file to startup grid. --> <beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation=" - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> + xmlns:util="http://www.springframework.org/schema/util" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/util + http://www.springframework.org/schema/util/spring-util.xsd"> <import resource="ignite-base-config.xml"/> - <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" parent="base-ignite.cfg"> <property name="localHost" value="127.0.0.1"/> + <property name="includeEventTypes"> + <util:constant static-field="org.apache.ignite.events.EventType.EVT_PAGE_REPLACEMENT_STARTED"/> + </property> + <property name="discoverySpi"> <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi"> <property name="ipFinder"> @@ -56,6 +62,7 @@ <bean class="org.apache.ignite.configuration.DataStorageConfiguration"> <property name="defaultDataRegionConfiguration"> <bean class="org.apache.ignite.configuration.DataRegionConfiguration"> + <property name="maxSize" value="#{300 * 1024 * 1024}"/> <property name="persistenceEnabled" value="true"/> </bean> </property> diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetWithPageReplacements.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetWithPageReplacements.java new file mode 100644 index 0000000..d6cbb64 --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetWithPageReplacements.java @@ -0,0 +1,172 @@ +/* + * 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.ignite.yardstick.cache; + +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.query.QueryCursor; +import org.apache.ignite.cache.query.ScanQuery; +import org.apache.ignite.cache.query.annotations.QuerySqlField; +import org.apache.ignite.events.Event; +import org.apache.ignite.lang.IgniteBiPredicate; +import org.yardstickframework.BenchmarkConfiguration; +import org.yardstickframework.BenchmarkUtils; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.atomic.AtomicBoolean; + +import static org.apache.ignite.events.EventType.EVT_PAGE_REPLACEMENT_STARTED; + +/** + * Ignite benchmark that performs payload with active page replacement. + * + * Test scenario: + * On setUp phase full fill cache until replace event occured, + * after proceed to fill two times more data. + * Execute full scan. + * + * On test phase fill data belonging to only 1/2 of dataregion capacity, calculated on setUp phase. + * + * NOTE: EVT_PAGE_REPLACEMENT_STARTED event need to be enabled on server side. + */ +public class IgnitePutGetWithPageReplacements extends IgniteCacheAbstractBenchmark<Integer, Object> { + /** Cache name. */ + private static final String CACHE_NAME = "CacheWithReplacement"; + + /** In mem reg capacity. */ + private volatile int replCntr = Integer.MAX_VALUE / 2; + + /** {@inheritDoc} */ + @Override public void setUp(BenchmarkConfiguration cfg) throws Exception { + super.setUp(cfg); + + int progress = 0; + + final AtomicBoolean replacement = new AtomicBoolean(); + + ignite().events().remoteListen(new IgniteBiPredicate<UUID, Event>() { + @Override public boolean apply(UUID uuid, Event evt) { + if (evt.type() == EVT_PAGE_REPLACEMENT_STARTED) { + replacement.set(true); + + return false; + } + + return true; + } + }, null, EVT_PAGE_REPLACEMENT_STARTED); + + int portion = 100; + + Map<Integer, TestValue> putMap = new HashMap<>(portion, 1.f); + + while (progress < 2 * replCntr) { + putMap.clear(); + + for (int i = 0; i < portion; i++) + putMap.put(progress + i, new TestValue(progress + i)); + + progress += portion; + + cache().putAll(putMap); + + if (progress % 1000 == 0) + BenchmarkUtils.println("progress=" + progress); + + if (replacement.compareAndSet(true, false)) { + if (replCntr != Integer.MAX_VALUE / 2) + throw new Exception("Invalid expected val: " + replCntr); + + replCntr = progress; + + BenchmarkUtils.println("replCntr=" + replCntr); + } + } + + BenchmarkUtils.println("DataRegion fullfill complete. progress=" + progress + " replCntr=" + replCntr + "."); + + int cacheSize = 0; + + try (QueryCursor cursor = cache.query(new ScanQuery())) { + for (Object o : cursor) + cacheSize++; + } + + BenchmarkUtils.println("cache size=" + cacheSize); + } + + /** */ + @Override protected IgniteCache<Integer, Object> cache() { + return ignite().getOrCreateCache(CACHE_NAME); + } + + /** {@inheritDoc} */ + @Override public boolean test(Map<Object, Object> map) throws Exception { + int portion = 100; + + Map<Integer, TestValue> putMap = new HashMap<>(portion, 1.f); + + ThreadLocalRandom rnd = ThreadLocalRandom.current(); + + for (int i = 0; i < portion; i++) { + int val = rnd.nextInt(replCntr / 2); + + putMap.put(val, new TestValue(val)); + } + + cache().putAll(putMap); + + return true; + } + + /** + * Class for test purpose. + */ + private static class TestValue implements Serializable { + /** */ + private int id; + + /** */ + @QuerySqlField(index = true) + private final byte[] payload = new byte[64]; + + /** + * @param id ID. + */ + private TestValue(int id) { + this.id = id; + } + + /** + * @return ID. + */ + public int getId() { + return id; + } + + /** + * @return Payload. + */ + public boolean hasPayload() { + return payload != null; + } + } +}