You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by mm...@apache.org on 2021/10/13 21:40:46 UTC

[ignite] branch master updated: IGNITE-15736 Add benchmarks for cache queries - scan, index, text) (#9491)

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 b98777f  IGNITE-15736 Add benchmarks for cache queries - scan, index, text) (#9491)
b98777f is described below

commit b98777f3a0f428664c81fde919d13835234fb089
Author: Maksim Timonin <ti...@gmail.com>
AuthorDate: Thu Oct 14 00:40:13 2021 +0300

    IGNITE-15736 Add benchmarks for cache queries - scan, index, text) (#9491)
---
 modules/yardstick/README.txt                       |   8 +-
 .../benchmark-cache-query-get-all.properties       |  89 ++++++++++++++++++
 modules/yardstick/config/ignite-base-config.xml    |   3 +
 .../cache/IgniteCacheQueryGetAllBenchmark.java     |  88 ++++++++++++++++++
 .../cache/IgniteIndexQueryGetAllBenchmark.java     |  35 +++++++
 .../cache/IgniteScanQueryGetAllBenchmark.java      |  31 +++++++
 .../cache/IgniteTextQueryGetAllBenchmark.java      |  32 +++++++
 .../yardstick/cache/model/PersonTextIndex.java     | 101 +++++++++++++++++++++
 8 files changed, 384 insertions(+), 3 deletions(-)

diff --git a/modules/yardstick/README.txt b/modules/yardstick/README.txt
index 45ff48d..8491f0a 100644
--- a/modules/yardstick/README.txt
+++ b/modules/yardstick/README.txt
@@ -102,8 +102,10 @@ 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.
-
+25. `IgnitePutGetWithPageReplacements` - benchmarks atomic cache put with active page replacement
+26. `IgniteScanQueryGetAllBenchmark` - benchmarks distributed ScanQuery
+27. `IgniteTextQueryGetAllBenchmark` - benchmarks distributed TextQuery
+28. `IgniteIndexQueryGetAllBenchmark` - benchmarks distributed IndexQuery.
 
 Properties And Command Line Arguments
 =====================================
@@ -156,4 +158,4 @@ Use Ignite Apache JIRA (https://issues.apache.org/jira/browse/IGNITE) to file bu
 
 License
 =======
-Yardstick Ignite is available under Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0.html) Open Source license.
\ No newline at end of file
+Yardstick Ignite is available under Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0.html) Open Source license.
diff --git a/modules/yardstick/config/benchmark-cache-query-get-all.properties b/modules/yardstick/config/benchmark-cache-query-get-all.properties
new file mode 100644
index 0000000..8aaba4b
--- /dev/null
+++ b/modules/yardstick/config/benchmark-cache-query-get-all.properties
@@ -0,0 +1,89 @@
+# 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.
+
+#
+# Contains benchmarks for cache queries.
+#
+
+# 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}" \
+# -Xms6g \
+# -Xmx6g \
+# -Xloggc:./gc${now0}.log \
+# -XX:+PrintGCDetails \
+# -verbose:gc \
+# -XX:+UseParNewGC \
+# -XX:+UseConcMarkSweepGC \
+# "
+
+#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
+
+# Packages where the specified benchmark is searched by reflection mechanism.
+BENCHMARK_PACKAGES=org.yardstickframework,org.apache.ignite.yardstick
+
+# Probe point writer class name.
+# BENCHMARK_WRITER=
+
+# Comma-separated list of the hosts to run BenchmarkServers on. 2 nodes on local host are enabled by default.
+SERVER_HOSTS=localhost,localhost
+
+# Comma-separated list of the hosts to run BenchmarkDrivers on. 1 node on local host is enabled by default.
+DRIVER_HOSTS=localhost
+
+# 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=1
+
+# Warmup.
+w=60
+
+# Duration.
+d=300
+
+# Threads count.
+t=64
+
+# Sync mode.
+sm=PRIMARY_SYNC
+
+# Jobs.
+j=10
+
+# Cache query keepBinary flag.
+kb=false
+
+# Cache query pageSize.
+ps=1024
+
+# Run configuration.
+CONFIGS="\
+-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -lfreq 1000 -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteScanQueryGetAllBenchmark -sn IgniteNode -ds ${ver}cache-query-scan -D keepBinary=${kb} -D pageSize=${ps},\
+-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -lfreq 1000 -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteTextQueryGetAllBenchmark -sn IgniteNode -ds ${ver}cache-query-text -D keepBinary=${kb} -D pageSize=${ps},\
+-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -lfreq 1000 -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteIndexQueryGetAllBenchmark -sn IgniteNode -ds ${ver}cache-query-index -D keepBinary=${kb} -D pageSize=${ps},\
+"
+
diff --git a/modules/yardstick/config/ignite-base-config.xml b/modules/yardstick/config/ignite-base-config.xml
index 99f2460..a38f50f 100644
--- a/modules/yardstick/config/ignite-base-config.xml
+++ b/modules/yardstick/config/ignite-base-config.xml
@@ -133,6 +133,9 @@
                             <value>org.apache.ignite.yardstick.cache.model.SampleValue</value>
 
                             <value>java.lang.Integer</value>
+                            <value>org.apache.ignite.yardstick.cache.model.PersonTextIndex</value>
+
+                            <value>java.lang.Integer</value>
                             <value>java.lang.Integer</value>
                         </list>
                     </property>
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheQueryGetAllBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheQueryGetAllBenchmark.java
new file mode 100644
index 0000000..f8bb255
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheQueryGetAllBenchmark.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.ignite.yardstick.cache;
+
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.cache.query.Query;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.yardstick.cache.model.PersonTextIndex;
+import org.yardstickframework.BenchmarkConfiguration;
+
+import static org.yardstickframework.BenchmarkUtils.println;
+
+/**
+ * Base class for cache queries benchmarks.
+ */
+abstract class IgniteCacheQueryGetAllBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
+    /** */
+    protected static final String namePrefix = "personName";
+
+    /** Cache query keep binary flag. */
+    private boolean keepBinary;
+
+    /** Cache query pageSize. */
+    private int pageSize;
+
+    /** {@inheritDoc} */
+    @Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
+        super.setUp(cfg);
+
+        keepBinary = args.getBooleanParameter("keepBinary", false);
+        pageSize = args.getIntParameter("pageSize", Query.DFLT_PAGE_SIZE);
+
+        println("Parameters of test: [keepBinary=" + keepBinary + "; pageSize=" + pageSize + "].");
+
+        loadCachesData();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void loadCacheData(String cacheName) {
+        try (IgniteDataStreamer<Integer, PersonTextIndex> dataLdr = ignite().dataStreamer(cacheName)) {
+            for (int i = 0; i < args.range() && !Thread.currentThread().isInterrupted(); i++) {
+                dataLdr.addData(i, new PersonTextIndex(i, namePrefix + i));
+
+                if (i % 100000 == 0)
+                    println(cfg, "Populated persons: " + i);
+            }
+        }
+    }
+
+    /** */
+    protected boolean testCacheQuery(Query<?> cacheQry) {
+        IgniteCache<Integer, Object> cache = cacheForOperation();
+
+        if (keepBinary)
+            cache = cache.withKeepBinary();
+
+        cacheQry.setPageSize(pageSize);
+
+        QueryCursor<?> cursor = cache.query(cacheQry);
+
+        for (Object o: cursor) {
+            // No-op.
+        }
+
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteCache<Integer, Object> cache() {
+        return ignite().cache("query");
+    }
+}
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteIndexQueryGetAllBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteIndexQueryGetAllBenchmark.java
new file mode 100644
index 0000000..ed06da9
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteIndexQueryGetAllBenchmark.java
@@ -0,0 +1,35 @@
+/*
+ * 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 java.util.Map;
+import org.apache.ignite.cache.query.IndexQuery;
+import org.apache.ignite.yardstick.cache.model.PersonTextIndex;
+
+import static org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.lt;
+
+/**
+ * Benchmark for IndexQuery.
+ */
+public class IgniteIndexQueryGetAllBenchmark extends IgniteCacheQueryGetAllBenchmark {
+    /** {@inheritDoc} */
+    @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+        return testCacheQuery(new IndexQuery<>(PersonTextIndex.class)
+            .setCriteria(lt("id", Integer.MAX_VALUE)));
+    }
+}
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteScanQueryGetAllBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteScanQueryGetAllBenchmark.java
new file mode 100644
index 0000000..5f5e378
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteScanQueryGetAllBenchmark.java
@@ -0,0 +1,31 @@
+/*
+ * 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 java.util.Map;
+import org.apache.ignite.cache.query.ScanQuery;
+
+/**
+ * Benchmark for ScanQuery.
+ */
+public class IgniteScanQueryGetAllBenchmark extends IgniteCacheQueryGetAllBenchmark {
+    /** {@inheritDoc} */
+    @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+        return testCacheQuery(new ScanQuery<>());
+    }
+}
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteTextQueryGetAllBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteTextQueryGetAllBenchmark.java
new file mode 100644
index 0000000..1010218
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteTextQueryGetAllBenchmark.java
@@ -0,0 +1,32 @@
+/*
+ * 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 java.util.Map;
+import org.apache.ignite.cache.query.TextQuery;
+import org.apache.ignite.yardstick.cache.model.PersonTextIndex;
+
+/**
+ * Benchmark for TextQuery.
+ */
+public class IgniteTextQueryGetAllBenchmark extends IgniteCacheQueryGetAllBenchmark {
+    /** {@inheritDoc} */
+    @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+        return testCacheQuery(new TextQuery<>(PersonTextIndex.class, namePrefix + "1000*"));
+    }
+}
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/model/PersonTextIndex.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/model/PersonTextIndex.java
new file mode 100644
index 0000000..3bb35fe
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/model/PersonTextIndex.java
@@ -0,0 +1,101 @@
+/*
+ * 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.model;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.cache.query.annotations.QueryTextField;
+
+/**
+ * Person record used for cache query test.
+ */
+public class PersonTextIndex implements Externalizable, Binarylizable {
+    /** Person ID. */
+    @QuerySqlField(index = true)
+    private int id;
+
+    /** Person name. */
+    @QueryTextField
+    private String name;
+
+    /**
+     * Constructs empty person.
+     */
+    public PersonTextIndex() {
+        // No-op.
+    }
+
+    /**
+     * Constructs person record.
+     *
+     * @param id Person ID.
+     * @param name Person name.
+     */
+    public PersonTextIndex(int id, String name) {
+        this.id = id;
+        this.name = name;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeInt(id);
+        out.writeUTF(name);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        id = in.readInt();
+        name = in.readUTF();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+        writer.writeInt("id", id);
+        writer.writeString("name", name);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+        id = reader.readInt("id");
+        name = reader.readString("name");
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        return this == o || (o instanceof PersonTextIndex) && id == ((PersonTextIndex)o).id;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        return id;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return "Person [name=" + name +
+            ", id=" + id +
+            ']';
+    }
+}