ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amashen...@apache.org
Subject [ignite] branch master updated: IGNITE-12353 Additional sql benchmarks which covers Date types and inlining usage. This closes #7040.
Date Mon, 02 Dec 2019 09:28:15 GMT
This is an automated email from the ASF dual-hosted git repository.

amashenkov 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 1599912  IGNITE-12353 Additional sql benchmarks which covers Date types and inlining
usage. This closes #7040.
1599912 is described below

commit 1599912004061b1c83ce055739feca156d8e1a48
Author: zstan <stanilovsky@gmail.com>
AuthorDate: Mon Dec 2 12:28:03 2019 +0300

    IGNITE-12353 Additional sql benchmarks which covers Date types and inlining usage. This
closes #7040.
---
 .../config/benchmark-native-sql-inline.properties  |  85 +++++++++++++
 .../apache/ignite/yardstick/jdbc/JdbcUtils.java    |  77 +++++++++++-
 .../jdbc/NativeSqlMixedDateInlineBenchmark.java    | 139 +++++++++++++++++++++
 3 files changed, 299 insertions(+), 2 deletions(-)

diff --git a/modules/yardstick/config/benchmark-native-sql-inline.properties b/modules/yardstick/config/benchmark-native-sql-inline.properties
new file mode 100644
index 0000000..758d577
--- /dev/null
+++ b/modules/yardstick/config/benchmark-native-sql-inline.properties
@@ -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.
+#
+
+#
+# Contains benchmarks for mixed queries with different inline size usage.
+#
+
+now0=`date +'%H%M%S'`
+
+# JVM options.
+JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false"
+
+JVM_OPTS=${JVM_OPTS}" \
+-Xms8g \
+-Xmx8g \
+-Xloggc:./gc${now0}.log \
+-XX:+PrintGCDetails \
+-verbose:gc \
+-XX:+UseG1GC \
+-XX:+PrintGCDateStamps \
+"
+
+#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=1
+
+# Warmup.
+w=30
+
+# Duration.
+d=300
+
+# 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} --sqlRange 1 -dn NativeSqlMixedDateInlineBenchmark -sn IgniteNode
-ds ${ver}sql-insert-delete-native-r1-${b}-backup -cl,\
+"
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/JdbcUtils.java
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/JdbcUtils.java
index 23fd04f..a3927b4 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/JdbcUtils.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/JdbcUtils.java
@@ -17,6 +17,8 @@
 
 package org.apache.ignite.yardstick.jdbc;
 
+import java.math.BigDecimal;
+import java.time.LocalDate;
 import org.apache.ignite.IgniteSemaphore;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.query.SqlFieldsQuery;
@@ -45,8 +47,8 @@ public class JdbcUtils {
             if (sem.tryAcquire()) {
                 println(cfg, "Create table...");
 
-                StringBuilder qry = new StringBuilder("CREATE TABLE test_long (id LONG PRIMARY
KEY, val LONG)" +
-                    " WITH \"wrap_value=true");
+                StringBuilder qry =
+                    new StringBuilder("CREATE TABLE test_long (id LONG PRIMARY KEY, val LONG)
WITH \"wrap_value=true");
 
                 if (atomicMode != null)
                     qry.append(", atomicity=").append(atomicMode.name());
@@ -88,4 +90,75 @@ public class JdbcUtils {
             sem.release();
         }
     }
+
+    /**
+     * Common method to fill test stand with data.
+     *
+     * @param cfg Benchmark configuration.
+     * @param ignite Ignite instance.
+     * @param tblName Table name for fill and creation.
+     * @param range Data key range.
+     * @param atomicMode Cache creation atomicity mode.
+     */
+    public static void fillTableWithIdx(BenchmarkConfiguration cfg,
+                                        IgniteEx ignite,
+                                        String tblName,
+                                        long range,
+                                        CacheAtomicityMode atomicMode) {
+        IgniteSemaphore sem = ignite.semaphore("sql-setup", 1, true, true);
+
+        try {
+            if (sem.tryAcquire()) {
+                println(cfg, "Create table...");
+
+                StringBuilder qry = new StringBuilder(String.format("CREATE TABLE %s (",
tblName) +
+                    "id LONG PRIMARY KEY, " +
+                    "DEC_COL DECIMAL, " +
+                    "DATE_COL DATE, " +
+                    "BIG_INT_COL BIGINT" +
+                    ") WITH \"wrap_value=true");
+
+                if (atomicMode != null)
+                    qry.append(", atomicity=").append(atomicMode.name());
+
+                qry.append("\";");
+
+                String qryStr = qry.toString();
+
+                println(cfg, "Creating table with schema: " + qryStr);
+
+                GridQueryProcessor qProc = ignite.context().query();
+
+                qProc.querySqlFields(new SqlFieldsQuery(qryStr), true);
+
+                println(cfg, "Populate data...");
+
+                for (long r = 1; r < range; ++r) {
+                    qProc.querySqlFields(
+                        new SqlFieldsQuery(String.format("INSERT INTO %s VALUES (?, ?, ?,
?)", tblName))
+                            .setArgs(r, new BigDecimal(r + 1), LocalDate.ofEpochDay(r), r
+ 2), true);
+
+                    if (r % 10000 == 0)
+                        println(cfg, "Populate " + r);
+                }
+
+                qProc.querySqlFields(new SqlFieldsQuery(String.format("CREATE INDEX idx1
ON %s (DEC_COL, " +
+                    "DATE_COL) inline_size 16", tblName)), true);
+
+                qProc.querySqlFields(new SqlFieldsQuery(String.format("CREATE INDEX idx2
ON %s (DATE_COL, " +
+                    "BIG_INT_COL) inline_size 16", tblName)), true);
+
+                println(cfg, "Finished populating data");
+            }
+            else {
+                // Acquire (wait setup by other client) and immediately release/
+                println(cfg, "Waits for setup...");
+
+                sem.acquire();
+            }
+        }
+        finally {
+            sem.release();
+        }
+    }
 }
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/NativeSqlMixedDateInlineBenchmark.java
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/NativeSqlMixedDateInlineBenchmark.java
new file mode 100644
index 0000000..df263e4
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/jdbc/NativeSqlMixedDateInlineBenchmark.java
@@ -0,0 +1,139 @@
+/*
+ * 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.jdbc;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.ignite.cache.query.FieldsQueryCursor;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.query.GridQueryProcessor;
+import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
+import org.yardstickframework.BenchmarkConfiguration;
+import org.yardstickframework.BenchmarkUtils;
+
+import static org.apache.ignite.yardstick.jdbc.JdbcUtils.fillTableWithIdx;
+
+/**
+ * Native sql benchmark that performs mixed insert/delete/select operations.
+ */
+public class NativeSqlMixedDateInlineBenchmark extends IgniteAbstractBenchmark {
+    /** */
+    private static final String TBL_NAME = NativeSqlMixedDateInlineBenchmark.class.getSimpleName().toUpperCase();
+
+    /** Digit pattern. */
+    private static final Pattern DIGIT_PATTERN = Pattern.compile("[0-9]+");
+
+    /** Dummy counter, just for possible jvm optimisation disable purpose. */
+    private long resCount;
+
+    /** */
+    private Integer getGroupNumber(Map<Object, Object> ctx) {
+        long tid = Thread.currentThread().getId();
+
+        Integer cnt = (Integer)ctx.get(tid);
+
+        if (cnt == null) {
+            Matcher matcher = DIGIT_PATTERN.matcher(Thread.currentThread().getName());
+
+            if (matcher.find()) {
+                cnt = Integer.parseInt(matcher.group());
+
+                ctx.put(tid, ++cnt);
+            }
+        }
+
+        return cnt;
+    }
+
+    /**
+     * Benchmarked action that inserts and immediately deletes row.
+     *
+     * @param ctx Operation context.
+     */
+    @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+        long insertKey = getGroupNumber(ctx) * args.range() + nextRandom(args.range() - 1);
+
+        String insertQry = String.format("INSERT INTO %s VALUES (?, ?, ?, ?)", TBL_NAME);
+
+        SqlFieldsQuery insert1 = new SqlFieldsQuery(insertQry);
+        insert1.setArgs(insertKey, new BigDecimal(insertKey + 1), LocalDate.ofEpochDay(insertKey),
insertKey + 2);
+
+        ++insertKey;
+
+        SqlFieldsQuery insert2 = new SqlFieldsQuery(insertQry);
+        insert2.setArgs(insertKey, new BigDecimal(insertKey + 1), LocalDate.ofEpochDay(insertKey),
insertKey + 2);
+
+        GridQueryProcessor qryProc = ((IgniteEx)ignite()).context().query();
+
+        long selectKey = nextRandom(args.range());
+
+        SqlFieldsQuery select1 = new SqlFieldsQuery(String.format("select * FROM %s where
DATE_COL >= ? " +
+            "and DATE_COL < ? and DEC_COL= ?", TBL_NAME));
+        select1.setArgs(LocalDate.ofEpochDay(selectKey), LocalDate.ofEpochDay(selectKey +
1), selectKey + 1);
+
+        SqlFieldsQuery select2 = new SqlFieldsQuery(String.format("select * FROM %s where
DATE_COL = ? " +
+            "and DEC_COL= ?", TBL_NAME));
+        select2.setArgs(LocalDate.ofEpochDay(selectKey), selectKey + 1);
+
+        SqlFieldsQuery delete1 = new SqlFieldsQuery(String.format("DELETE FROM %s WHERE id
= ?", TBL_NAME));
+        delete1.setArgs(--insertKey);
+
+        SqlFieldsQuery delete2 = new SqlFieldsQuery(String.format("DELETE FROM %s WHERE DATE_COL
= ?", TBL_NAME));
+        delete2.setArgs(LocalDate.ofEpochDay(++insertKey));
+
+        try (FieldsQueryCursor<List<?>> insCur1 = qryProc.querySqlFields(insert1,
false);
+             FieldsQueryCursor<List<?>> insCur2 = qryProc.querySqlFields(insert2,
false);
+             FieldsQueryCursor<List<?>> selCur1 = qryProc.querySqlFields(select1,
false);
+             FieldsQueryCursor<List<?>> selCur2 = qryProc.querySqlFields(select2,
false);
+             FieldsQueryCursor<List<?>> delCur1 = qryProc.querySqlFields(delete1,
false);
+             FieldsQueryCursor<List<?>> delCur2 = qryProc.querySqlFields(delete2,
false)) {
+
+            resCount += insCur1.getAll().size();
+            resCount += insCur2.getAll().size();
+            resCount += selCur1.getAll().size();
+            resCount += selCur2.getAll().size();
+            resCount += delCur1.getAll().size();
+            resCount += delCur2.getAll().size();
+        }
+        catch (Exception e) {
+            BenchmarkUtils.error("error: ", e);
+        }
+
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
+        super.setUp(cfg);
+
+        fillTableWithIdx(cfg, (IgniteEx)ignite(), TBL_NAME, args.range(), args.atomicMode());
+    }
+
+    /** {@inheritDoc} */
+    @Override public void tearDown() throws Exception {
+        super.tearDown();
+
+        BenchmarkUtils.println("Summary results: " + resCount);
+    }
+}


Mime
View raw message