<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Benchmark on Mini Fish</title>
    <link>https://blog.minifish.org/tags/benchmark/</link>
    <description>Recent content in Benchmark on Mini Fish</description>
    <image>
      <title>Mini Fish</title>
      <url>https://blog.minifish.org/android-chrome-512x512.png</url>
      <link>https://blog.minifish.org/android-chrome-512x512.png</link>
    </image>
    <generator>Hugo -- 0.154.5</generator>
    <language>en-US</language>
    <copyright>Mini Fish 2014-present. Licensed under CC-BY-NC</copyright>
    <lastBuildDate>Mon, 14 Dec 2020 12:06:00 +0800</lastBuildDate>
    <atom:link href="https://blog.minifish.org/tags/benchmark/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>How to Implement a Simple Load Using Sysbench</title>
      <link>https://blog.minifish.org/posts/how-to-implement-a-simple-load-using-sysbench/</link>
      <pubDate>Mon, 14 Dec 2020 12:06:00 +0800</pubDate>
      <guid>https://blog.minifish.org/posts/how-to-implement-a-simple-load-using-sysbench/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://github.com/akopytov/sysbench&#34;&gt;Sysbench&lt;/a&gt; is a tool commonly used in database testing. Since version 1.0, it has supported more powerful custom functions, allowing users to conveniently write some Lua scripts to simulate load. The purpose of writing this article is, firstly, because I wanted to explore Sysbench&amp;rsquo;s custom load usage. Secondly, because I tried the mysqlslap tool provided by MySQL&amp;rsquo;s official source, and found that it freezes easily during database performance testing, which could mislead users into thinking there is an issue with the database, causing trouble for many. Therefore, I want to help people avoid these pitfalls.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p><a href="https://github.com/akopytov/sysbench">Sysbench</a> is a tool commonly used in database testing. Since version 1.0, it has supported more powerful custom functions, allowing users to conveniently write some Lua scripts to simulate load. The purpose of writing this article is, firstly, because I wanted to explore Sysbench&rsquo;s custom load usage. Secondly, because I tried the mysqlslap tool provided by MySQL&rsquo;s official source, and found that it freezes easily during database performance testing, which could mislead users into thinking there is an issue with the database, causing trouble for many. Therefore, I want to help people avoid these pitfalls.</p>
<h2 id="a-simple-example">A Simple Example</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-lua" data-lang="lua"><span style="display:flex;"><span><span style="color:#75715e">#!/usr/bin/env sysbench</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>require(<span style="color:#e6db74">&#34;oltp_common&#34;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">function</span> <span style="color:#a6e22e">prepare_statements</span>()
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">end</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">function</span> <span style="color:#a6e22e">event</span>()
</span></span><span style="display:flex;"><span>    con:query(<span style="color:#e6db74">&#34;set autocommit = 1&#34;</span>)
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">end</span>
</span></span></code></pre></div><p>The first line <code>require</code> includes Sysbench&rsquo;s built-in basic library; the empty <code>prepare_statement</code> is a callback function from <code>oltp_common</code> that must be present; the specific execution of a single load is implemented in the <code>event</code> function.</p>
<p>Save this script as a Lua file, for example, named set.lua, and then execute it using sysbench.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>sysbench --config-file<span style="color:#f92672">=</span>config --threads<span style="color:#f92672">=</span><span style="color:#ae81ff">100</span> set.lua --tables<span style="color:#f92672">=</span><span style="color:#ae81ff">1</span> --table_size<span style="color:#f92672">=</span><span style="color:#ae81ff">1000000</span> run
</span></span></code></pre></div><p>You can use the above command. Of course, here <code>--tables=1</code> and <code>--table_size=1000000</code> are not useful for this load, so they are optional. <code>--threads</code> controls concurrency.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>$ cat config
</span></span><span style="display:flex;"><span>time<span style="color:#f92672">=</span><span style="color:#ae81ff">120</span>
</span></span><span style="display:flex;"><span>db-driver<span style="color:#f92672">=</span>mysql
</span></span><span style="display:flex;"><span>mysql-host<span style="color:#f92672">=</span>172.16.5.33
</span></span><span style="display:flex;"><span>mysql-port<span style="color:#f92672">=</span><span style="color:#ae81ff">34000</span>
</span></span><span style="display:flex;"><span>mysql-user<span style="color:#f92672">=</span>root
</span></span><span style="display:flex;"><span>mysql-db<span style="color:#f92672">=</span>sbtest
</span></span><span style="display:flex;"><span>report-interval<span style="color:#f92672">=</span><span style="color:#ae81ff">10</span>
</span></span></code></pre></div><p>In the config file, parameters you don&rsquo;t frequently adjust are written once to avoid having a long string of parameters in the command line. These are required fields: <code>time</code> represents the test duration, <code>report-interval</code> is used to observe real-time performance results, and the others pertain to how to connect to the database.</p>
<p>The running output generally looks like:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-text" data-lang="text"><span style="display:flex;"><span>[ 10s ] thds: 100 tps: 94574.34 qps: 94574.34 (r/w/o: 0.00/0.00/94574.34) lat (ms,95%): 3.68 err/s: 0.00 reconn/s: 0.00
</span></span><span style="display:flex;"><span>[ 20s ] thds: 100 tps: 77720.30 qps: 77720.30 (r/w/o: 0.00/0.00/77720.30) lat (ms,95%): 5.28 err/s: 0.00 reconn/s: 0.00
</span></span><span style="display:flex;"><span>[ 30s ] thds: 100 tps: 56080.10 qps: 56080.10 (r/w/o: 0.00/0.00/56080.10) lat (ms,95%): 9.22 err/s: 0.00 reconn/s: 0.00
</span></span><span style="display:flex;"><span>[ 40s ] thds: 100 tps: 93315.90 qps: 93315.90 (r/w/o: 0.00/0.00/93315.90) lat (ms,95%): 4.82 err/s: 0.00 reconn/s: 0.00
</span></span><span style="display:flex;"><span>[ 50s ] thds: 100 tps: 97491.02 qps: 97491.02 (r/w/o: 0.00/0.00/97491.02) lat (ms,95%): 4.65 err/s: 0.00 reconn/s: 0.00
</span></span><span style="display:flex;"><span>[ 60s ] thds: 100 tps: 94034.27 qps: 94034.27 (r/w/o: 0.00/0.00/94034.27) lat (ms,95%): 4.91 err/s: 0.00 reconn/s: 0.00
</span></span><span style="display:flex;"><span>[ 70s ] thds: 100 tps: 74707.37 qps: 74707.37 (r/w/o: 0.00/0.00/74707.37) lat (ms,95%): 6.79 err/s: 0.00 reconn/s: 0.00
</span></span><span style="display:flex;"><span>[ 80s ] thds: 100 tps: 89485.10 qps: 89485.10 (r/w/o: 0.00/0.00/89485.10) lat (ms,95%): 5.18 err/s: 0.00 reconn/s: 0.00
</span></span><span style="display:flex;"><span>[ 90s ] thds: 100 tps: 109296.44 qps: 109296.44 (r/w/o: 0.00/0.00/109296.44) lat (ms,95%): 2.91 err/s: 0.00 reconn/s: 0.00
</span></span></code></pre></div><p>Finally, there will be a summary report.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-text" data-lang="text"><span style="display:flex;"><span>SQL statistics:
</span></span><span style="display:flex;"><span>    queries performed:
</span></span><span style="display:flex;"><span>        read:                            0
</span></span><span style="display:flex;"><span>        write:                           0
</span></span><span style="display:flex;"><span>        other:                           10424012
</span></span><span style="display:flex;"><span>        total:                           10424012
</span></span><span style="display:flex;"><span>    transactions:                        10424012 (86855.65 per sec.)
</span></span><span style="display:flex;"><span>    queries:                             10424012 (86855.65 per sec.)
</span></span><span style="display:flex;"><span>    ignored errors:                      0      (0.00 per sec.)
</span></span><span style="display:flex;"><span>    reconnects:                          0      (0.00 per sec.)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Throughput:
</span></span><span style="display:flex;"><span>    events/s (eps):                      86855.6517
</span></span><span style="display:flex;"><span>    time elapsed:                        120.0154s
</span></span><span style="display:flex;"><span>    total number of events:              10424012
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Latency (ms):
</span></span><span style="display:flex;"><span>         min:                                    0.09
</span></span><span style="display:flex;"><span>         avg:                                    1.15
</span></span><span style="display:flex;"><span>         max:                                 1527.74
</span></span><span style="display:flex;"><span>         95th percentile:                        4.91
</span></span><span style="display:flex;"><span>         sum:                             11994122.49
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Threads fairness:
</span></span><span style="display:flex;"><span>    events (avg/stddev):           104240.1200/600.21
</span></span><span style="display:flex;"><span>    execution time (avg/stddev):   119.9412/0.01
</span></span></code></pre></div>]]></content:encoded>
    </item>
    <item>
      <title>How to Test CockroachDB Performance Using Benchmarksql</title>
      <link>https://blog.minifish.org/posts/how-to-test-cockroachdb-performance-using-benchmarksql/</link>
      <pubDate>Fri, 06 Jul 2018 21:21:00 +0800</pubDate>
      <guid>https://blog.minifish.org/posts/how-to-test-cockroachdb-performance-using-benchmarksql/</guid>
      <description>&lt;h2 id=&#34;why-test-tpc-c&#34;&gt;Why Test TPC-C&lt;/h2&gt;
&lt;p&gt;First of all, TPC-C is the de facto OLTP benchmark standard. It is a set of specifications, and any database can publish its test results under this standard, so there&amp;rsquo;s no issue of quarreling over the testing tools used.&lt;/p&gt;
&lt;p&gt;Secondly, TPC-C is closer to real-world scenarios as it includes a transaction model within it. In the flow of this transaction model, there are both high-frequency simple transaction statements and low-frequency inventory query statements. Therefore, it tests the database more comprehensively and practically.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h2 id="why-test-tpc-c">Why Test TPC-C</h2>
<p>First of all, TPC-C is the de facto OLTP benchmark standard. It is a set of specifications, and any database can publish its test results under this standard, so there&rsquo;s no issue of quarreling over the testing tools used.</p>
<p>Secondly, TPC-C is closer to real-world scenarios as it includes a transaction model within it. In the flow of this transaction model, there are both high-frequency simple transaction statements and low-frequency inventory query statements. Therefore, it tests the database more comprehensively and practically.</p>
<h2 id="testing-tpc-c-on-cockroachdb">Testing TPC-C on CockroachDB</h2>
<p>This year, CockroachDB released its TPC-C performance results. However, unfortunately, they did not use a tool recognized by the database industry that implements the TPC-C standard for testing. Instead, they used their own implementation of a TPC-C tool. The compliance level of this tool was not recognized. In the white paper officially released by them, it is also mentioned that this TPC-C cannot be compared with the TPC-C standard.</p>
<p>Therefore, I thought of using a highly recognized tool in the industry for testing. Here, I chose Benchmarksql version 5.0.</p>
<p>Benchmarksql 5.0 supports the PostgreSQL protocol, Oracle protocol, and MySQL protocol (the MySQL protocol is supported in the code, but the author hasn&rsquo;t fully tested it, so the official documentation doesn&rsquo;t mention MySQL). Among these, the PostgreSQL protocol is supported by CockroachDB.</p>
<h3 id="test-preparation">Test Preparation</h3>
<p>After preparing the Benchmarksql code, don&rsquo;t rush into testing. There are three main pitfalls here that need to be addressed first.</p>
<ol>
<li>
<p><strong>CockroachDB does not support adding a primary key after table creation.</strong> Therefore, you need to include the primary key when creating the table. Specifically, in the <code>run</code> folder under the root directory of the Benchmarksql code, create a <code>sql.cdb</code> folder. Copy <code>tableCreates.sql</code> and <code>indexCreates.sql</code> from the <code>sql.common</code> folder at the same level into <code>sql.cdb</code>. Then move the primary keys in <code>indexCreates.sql</code> into the table creation statements in <code>tableCreates.sql</code>. For how to define indexes while creating tables, please refer to the database documentation syntax via Google.</p>
</li>
<li>
<p><strong>CockroachDB is a &ldquo;strongly typed&rdquo; database.</strong> This is my own way of describing it. It has a rather peculiar behavior: when you add different data types (e.g., int + float), it will report an error saying, &ldquo;InternalError: unsupported binary operator: &lt;int&gt; + &lt;float&gt;&rdquo;. Generally, databases don&rsquo;t behave like this; most would perform some implicit conversions, or in other words, they are very tolerant of SQL writers. But CockroachDB is unique in that if you don&rsquo;t specify the type, it reports an error. This greatly reduces the burden of type inference in its internal implementation.</p>
<p>This behavior causes Benchmarksql to fail to run the tests properly. The solution is to add the required type at the position where the error occurs. For example, change <code>update t set i = i + ?;</code> (the <code>?</code> is generally filled in using <code>prepare/execute</code>) to <code>update t set i = i + ?::DECIMAL;</code>. Yes, CockroachDB specifies types explicitly by adding <code>::&lt;type_name&gt;</code> at the end. But strangely, not all additions require type specification.</p>
</li>
<li>
<p><strong>CockroachDB does not support <code>SELECT FOR UPDATE</code>.</strong> This is the easiest to solve: comment out all <code>FOR UPDATE</code> clauses in Benchmarksql. CockroachDB itself supports the serializable isolation level; lacking <code>FOR UPDATE</code> doesn&rsquo;t affect consistency.</p>
</li>
</ol>
<h3 id="starting-the-test">Starting the Test</h3>
<p>After overcoming the pitfalls mentioned above, you can proceed with the normal testing process: creating the database, creating tables and indexes, importing data, and testing. You can refer to Benchmarksql&rsquo;s <code>HOW-TO-RUN.txt</code>.</p>
<h3 id="test-results">Test Results</h3>
<p>On my test machine with 40 cores, 128 GB of memory, and SSD, under 100 warehouses, the tpmC is approximately 5,000. This is about one-tenth of PostgreSQL 10 on the same machine. PostgreSQL can reach around 500,000 tpmC.</p>
]]></content:encoded>
    </item>
    <item>
      <title>How to Test CockroachDB Performance Using Sysbench</title>
      <link>https://blog.minifish.org/posts/how-to-test-cockroachdb-performance-using-sysbench/</link>
      <pubDate>Mon, 11 Jun 2018 13:50:00 +0800</pubDate>
      <guid>https://blog.minifish.org/posts/how-to-test-cockroachdb-performance-using-sysbench/</guid>
      <description>&lt;h2 id=&#34;compiling-sysbench-with-pgsql-support&#34;&gt;Compiling Sysbench with pgsql Support&lt;/h2&gt;
&lt;p&gt;CockroachDB uses the PostgreSQL protocol. If you want to use Sysbench for testing, you need to enable pg protocol support in Sysbench. Sysbench already supports the pg protocol, but it is not enabled by default during compilation. You can configure it with the following command:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-shell&#34; data-lang=&#34;shell&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;./configure --with-pgsql
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Of course, preliminary work involves downloading the Sysbench source code and installing the necessary PostgreSQL header files required for compilation (you can use &lt;code&gt;yum&lt;/code&gt; or &lt;code&gt;sudo&lt;/code&gt; to install them).&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h2 id="compiling-sysbench-with-pgsql-support">Compiling Sysbench with pgsql Support</h2>
<p>CockroachDB uses the PostgreSQL protocol. If you want to use Sysbench for testing, you need to enable pg protocol support in Sysbench. Sysbench already supports the pg protocol, but it is not enabled by default during compilation. You can configure it with the following command:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>./configure --with-pgsql
</span></span></code></pre></div><p>Of course, preliminary work involves downloading the Sysbench source code and installing the necessary PostgreSQL header files required for compilation (you can use <code>yum</code> or <code>sudo</code> to install them).</p>
<h2 id="testing">Testing</h2>
<p>The testing method is no different from testing MySQL or PostgreSQL; you can test any of the create, read, update, delete (CRUD) operations you like. The only thing to note is to set <code>auto_inc</code> to <code>off</code>.</p>
<p>This is because CockroachDB&rsquo;s auto-increment behavior is different from PostgreSQL&rsquo;s. It generates a unique <code>id</code>, but it does not guarantee that the <code>id</code>s are sequential or incremental. This is fine when inserting data. However, during delete, update, or query operations, since all SQL statements use <code>id</code> as the condition for these operations, you may encounter situations where data cannot be found.</p>
<p>That is:</p>
<p>When <code>auto_inc = on</code> (which is the default value in Sysbench)</p>
<h3 id="table-structure">Table Structure</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sql" data-lang="sql"><span style="display:flex;"><span><span style="color:#66d9ef">CREATE</span> <span style="color:#66d9ef">TABLE</span> sbtest1 (
</span></span><span style="display:flex;"><span>   id INT <span style="color:#66d9ef">NOT</span> <span style="color:#66d9ef">NULL</span> <span style="color:#66d9ef">DEFAULT</span> unique_rowid(),
</span></span><span style="display:flex;"><span>   k INTEGER <span style="color:#66d9ef">NOT</span> <span style="color:#66d9ef">NULL</span> <span style="color:#66d9ef">DEFAULT</span> <span style="color:#ae81ff">0</span>:::INT,
</span></span><span style="display:flex;"><span>   <span style="color:#66d9ef">c</span> STRING(<span style="color:#ae81ff">120</span>) <span style="color:#66d9ef">NOT</span> <span style="color:#66d9ef">NULL</span> <span style="color:#66d9ef">DEFAULT</span> <span style="color:#e6db74">&#39;&#39;</span>:::STRING,
</span></span><span style="display:flex;"><span>   <span style="color:#66d9ef">pad</span> STRING(<span style="color:#ae81ff">60</span>) <span style="color:#66d9ef">NOT</span> <span style="color:#66d9ef">NULL</span> <span style="color:#66d9ef">DEFAULT</span> <span style="color:#e6db74">&#39;&#39;</span>:::STRING,
</span></span><span style="display:flex;"><span>   <span style="color:#66d9ef">CONSTRAINT</span> <span style="color:#e6db74">&#34;&#34;</span><span style="color:#66d9ef">primary</span><span style="color:#e6db74">&#34;&#34;</span> <span style="color:#66d9ef">PRIMARY</span> <span style="color:#66d9ef">KEY</span> (id <span style="color:#66d9ef">ASC</span>),
</span></span><span style="display:flex;"><span>   <span style="color:#66d9ef">INDEX</span> k_1 (k <span style="color:#66d9ef">ASC</span>),
</span></span><span style="display:flex;"><span>   FAMILY <span style="color:#e6db74">&#34;&#34;</span><span style="color:#66d9ef">primary</span><span style="color:#e6db74">&#34;&#34;</span> (id, k, <span style="color:#66d9ef">c</span>, <span style="color:#66d9ef">pad</span>)
</span></span><span style="display:flex;"><span>)
</span></span></code></pre></div><h3 id="data">Data</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sql" data-lang="sql"><span style="display:flex;"><span>root<span style="color:#f92672">@</span>:<span style="color:#ae81ff">26257</span><span style="color:#f92672">/</span>sbtest<span style="color:#f92672">&gt;</span> <span style="color:#66d9ef">SELECT</span> id <span style="color:#66d9ef">FROM</span> sbtest1 <span style="color:#66d9ef">ORDER</span> <span style="color:#66d9ef">BY</span> id <span style="color:#66d9ef">LIMIT</span> <span style="color:#ae81ff">1</span>;
</span></span><span style="display:flex;"><span><span style="color:#f92672">+</span><span style="color:#75715e">--------------------+
</span></span></span><span style="display:flex;"><span><span style="color:#f92672">|</span>         id         <span style="color:#f92672">|</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">+</span><span style="color:#75715e">--------------------+
</span></span></span><span style="display:flex;"><span><span style="color:#f92672">|</span> <span style="color:#ae81ff">354033003848892419</span> <span style="color:#f92672">|</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">+</span><span style="color:#75715e">--------------------+
</span></span></span></code></pre></div><p>As you can see, the data does not start from <code>1</code>, nor is it sequential. Normally, the <code>id</code> in a Sysbench table should be within the range <code>[1, table_size]</code>.</p>
<h3 id="sql">SQL</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sql" data-lang="sql"><span style="display:flex;"><span><span style="color:#66d9ef">UPDATE</span> sbtest<span style="color:#f92672">%</span>u <span style="color:#66d9ef">SET</span> k <span style="color:#f92672">=</span> k <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span> <span style="color:#66d9ef">WHERE</span> id <span style="color:#f92672">=</span> <span style="color:#f92672">?</span>
</span></span></code></pre></div><p>Taking the <code>UPDATE</code> statement as an example, <code>id</code> is used as the query condition. Sysbench assumes that this <code>id</code> should be between <code>[1, table_size]</code>, but in reality, it&rsquo;s not.</p>
<h3 id="example-of-correct-testing-command-line">Example of Correct Testing Command Line</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>sysbench --db-driver<span style="color:#f92672">=</span>pgsql --pgsql-host<span style="color:#f92672">=</span>127.0.0.1 --pgsql-port<span style="color:#f92672">=</span><span style="color:#ae81ff">26257</span> --pgsql-user<span style="color:#f92672">=</span>root --pgsql-db<span style="color:#f92672">=</span>sbtest <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>        --time<span style="color:#f92672">=</span><span style="color:#ae81ff">180</span> --threads<span style="color:#f92672">=</span><span style="color:#ae81ff">50</span> --report-interval<span style="color:#f92672">=</span><span style="color:#ae81ff">10</span> --tables<span style="color:#f92672">=</span><span style="color:#ae81ff">32</span> --table-size<span style="color:#f92672">=</span><span style="color:#ae81ff">10000000</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>        oltp_update_index <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>        --sum_ranges<span style="color:#f92672">=</span><span style="color:#ae81ff">50</span> --distinct_ranges<span style="color:#f92672">=</span><span style="color:#ae81ff">50</span> --range_size<span style="color:#f92672">=</span><span style="color:#ae81ff">100</span> --simple_ranges<span style="color:#f92672">=</span><span style="color:#ae81ff">100</span> --order_ranges<span style="color:#f92672">=</span><span style="color:#ae81ff">100</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>        --index_updates<span style="color:#f92672">=</span><span style="color:#ae81ff">100</span> --non_index_updates<span style="color:#f92672">=</span><span style="color:#ae81ff">10</span> --auto_inc<span style="color:#f92672">=</span>off prepare/run/cleanup
</span></span></code></pre></div><h3 id="insert-testing">INSERT Testing</h3>
<p>Let&rsquo;s discuss the INSERT test separately. The INSERT test refers to Sysbench&rsquo;s <code>oltp_insert</code>. The characteristic of this test is that when <code>auto_inc</code> is <code>on</code>, data is inserted during the prepare phase of the test; otherwise, only the table is created without inserting data. Because when <code>auto_inc</code> is <code>on</code>, after the prepare phase, during the run phase, the inserted data will not cause conflicts due to the guarantee of the auto-increment column. When <code>auto_inc</code> is <code>off</code>, the <code>id</code> of the data inserted during the run phase is randomly assigned, which aligns with some actual testing scenarios.</p>
<p>For CockroachDB, when testing INSERT operations with <code>auto_inc</code> set to <code>off</code>, after the prepare phase, during the run phase of data insertion, you can observe the monitoring metrics (by connecting to CockroachDB&rsquo;s HTTP port) under the &ldquo;Distribution&rdquo; section in &ldquo;KV Transactions&rdquo;. You&rsquo;ll notice a large number of &ldquo;Fast-path Committed&rdquo; transactions. This indicates that transactions are committed using one-phase commit (1PC). That is, the data involved in the transaction does not span across CockroachDB nodes, so there&rsquo;s no need to ensure consistency through two-phase commit transactions. This is an optimization in CockroachDB, which is very effective in INSERT tests and can deliver excellent performance.</p>
<p>If <code>auto_inc</code> is <code>on</code>, although for other tests that require read-before-write operations, the results in CockroachDB might be inflated, it is still fair for the INSERT test. If time permits, you can supplement the tests to see the differences.</p>
]]></content:encoded>
    </item>
    <item>
      <title>How to View CMU DB Group&#39;s OLTP-Bench</title>
      <link>https://blog.minifish.org/posts/how-to-view-cmu-db-groups-oltp-bench/</link>
      <pubDate>Fri, 23 Feb 2018 00:00:00 +0000</pubDate>
      <guid>https://blog.minifish.org/posts/how-to-view-cmu-db-groups-oltp-bench/</guid>
      <description>&lt;h2 id=&#34;introduction-to-oltp-bench&#34;&gt;Introduction to OLTP-Bench&lt;/h2&gt;
&lt;p&gt;OLTP-Bench is an open-source benchmarking tool platform for OLTP scenarios from CMU&amp;rsquo;s DB Group. It was designed to provide a simple, easy-to-use, and extensible testing platform.&lt;/p&gt;
&lt;p&gt;It connects to databases via the JDBC interface, supporting the following test suites:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;TPC-C&lt;/li&gt;
&lt;li&gt;Wikipedia&lt;/li&gt;
&lt;li&gt;Synthetic Resource Stresser&lt;/li&gt;
&lt;li&gt;Twitter&lt;/li&gt;
&lt;li&gt;Epinions.com&lt;/li&gt;
&lt;li&gt;TATP&lt;/li&gt;
&lt;li&gt;AuctionMark&lt;/li&gt;
&lt;li&gt;SEATS&lt;/li&gt;
&lt;li&gt;YCSB&lt;/li&gt;
&lt;li&gt;JPAB (Hibernate)&lt;/li&gt;
&lt;li&gt;CH-benCHmark&lt;/li&gt;
&lt;li&gt;Voter (Japanese &amp;ldquo;American Idol&amp;rdquo;)&lt;/li&gt;
&lt;li&gt;SIBench (Snapshot Isolation)&lt;/li&gt;
&lt;li&gt;SmallBank&lt;/li&gt;
&lt;li&gt;LinkBench&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Detailed project information can be found &lt;a href=&#34;http://db.cs.cmu.edu/projects/oltp-bench/&#34;&gt;here&lt;/a&gt;, and the GitHub page is &lt;a href=&#34;https://github.com/oltpbenchmark/oltpbench&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h2 id="introduction-to-oltp-bench">Introduction to OLTP-Bench</h2>
<p>OLTP-Bench is an open-source benchmarking tool platform for OLTP scenarios from CMU&rsquo;s DB Group. It was designed to provide a simple, easy-to-use, and extensible testing platform.</p>
<p>It connects to databases via the JDBC interface, supporting the following test suites:</p>
<ul>
<li>TPC-C</li>
<li>Wikipedia</li>
<li>Synthetic Resource Stresser</li>
<li>Twitter</li>
<li>Epinions.com</li>
<li>TATP</li>
<li>AuctionMark</li>
<li>SEATS</li>
<li>YCSB</li>
<li>JPAB (Hibernate)</li>
<li>CH-benCHmark</li>
<li>Voter (Japanese &ldquo;American Idol&rdquo;)</li>
<li>SIBench (Snapshot Isolation)</li>
<li>SmallBank</li>
<li>LinkBench</li>
</ul>
<p>Detailed project information can be found <a href="http://db.cs.cmu.edu/projects/oltp-bench/">here</a>, and the GitHub page is <a href="https://github.com/oltpbenchmark/oltpbench">here</a>.</p>
<p>The project introduction page includes three papers published by the authors, with the one from 2013 being the most important, also linked on the GitHub page.</p>
<p>Based on the GitHub page, the project does not seem to have a high level of attention and has not been very active recently. Most issues and pull requests come from within CMU.</p>
<h2 id="oltp-bench-an-extensible-testbed-for-benchmarking-relational-databases">OLTP-Bench: An Extensible Testbed for Benchmarking Relational Databases</h2>
<p>The paper &ldquo;OLTP-Bench: An Extensible Testbed for Benchmarking Relational Databases&rdquo; can be regarded as the most detailed introduction to this project.</p>
<p>In the first and second chapters, the authors introduce the motivation for creating this framework, which is to integrate multiple test sets and provide features that simple benchmarking tools do not have, while offering excellent extensibility to attract developers to support more databases.</p>
<p>From the activity on GitHub, it is evident that this extensibility is more about adding database support rather than test sets. However, the number of supported test suites is already quite extensive.</p>
<p>Chapter three introduces the architectural design, with a focus on test suite management, load generators, SQL syntax conversion, multi-client scenarios (similar to multiple sysbench instances stressing a single MySQL), and result collection.</p>
<p>Chapter four discusses the supported test suites. I&rsquo;m only familiar with TPCC and YCSB. The authors classify them from three perspectives:</p>
<ol>
<li>Transaction-focused, such as TPCC and SmallBank</li>
<li>Internet applications, like LinkBench and Wikipedia</li>
<li>Specialized tests, such as YCSB and SIBench</li>
</ol>
<p>Further details can be seen in the table:
[table]</p>
<p>Chapter five describes the demo deployment environment, with subsequent sections introducing the demo&rsquo;s features.</p>
<p>Chapter six uses the demo from the previous chapter to introduce features, analyzed as follows:</p>
<ol>
<li>
<p>Rate control. It seems odd for a benchmarking tool to perform rate control, as the conventional understanding is to push performance as high as possible to gauge system limits. The paper provides an example using the Wikipedia test suite, increasing by 25 TPS every 10 seconds to observe database latency changes.</p>
</li>
<li>
<p>Tagging different transactions in the same test suite for separate statistics – using TPCC as an example to statistically categorize transactions from different stages.</p>
</li>
<li>
<p>Modifying load content, like switching from read-only to write-only loads.</p>
</li>
<li>
<p>Changing the method for load randomness.</p>
</li>
<li>
<p>Monitoring server status alongside database monitoring by deploying an OLTP-Bench monitor on the server.</p>
</li>
<li>
<p>Running multiple test suites simultaneously, such as running TPCC and YCSB concurrently.</p>
</li>
<li>
<p>Multi-client usage, mentioned in chapter three.</p>
</li>
<li>
<p>Repeatability. To prove OLTP-Bench results are genuine and reliable, the authors tested PG&rsquo;s SSI performance using SIBench from the tool on similarly configured machines, achieving results consistent with those in PG&rsquo;s SSI paper.</p>
</li>
</ol>
<p>In summary, rate control and transaction tagging stand out as novel features, while the rest are not particularly special.</p>
<p>Chapter seven is arguably the most valuable part of the article, discussing cloud environments where users might only have database access and not server control. Users may struggle to assess the cost-effectiveness of different cloud database services or configurations due to charges encompassing CPU, storage, network, and asynchronous sync in some architectures. Thus, using benchmarking tools to derive performance and subsequently calculate cost-effectiveness is particularly worthwhile. This chapter compares varying perspectives: different service providers, configurations, comparing databases on the same configuration, and presents the cost-effectiveness outcomes.</p>
<p>In chapter eight, the authors compare OLTP-Bench with other similar tools, providing a favorable self-assessment.</p>
<p>Chapter nine outlines the authors’ future plans, including support for pure NoSQL, additional databases&rsquo; proprietary SQL syntax, generating real-world load distributions from production data, and support for stored procedures.</p>
<p>In conclusion, as the authors mentioned, this is an integrative framework where ease of use and extensibility are key.</p>
<h2 id="usage-summary">Usage Summary</h2>
<p>OLTP-Bench is relatively simple to install and use, especially the deployment. Its cross-platform nature provides a better user experience compared to traditional tpcc and sysbench. Usage is relatively straightforward due to the plethora of test configuration templates provided, allowing easy initiation of tests with simple configuration file modifications. The test results are stable, although certain features mentioned in papers, like server status monitoring, still require exploration.</p>
<p>I tested all 15 test suites on MySQL 5.7 and TiDB, obtaining the following results:
[table]</p>
<p>Its usability is quite evident. As for the ease of secondary development, it should be relatively simple, considering the entire OLTP-Bench project is not particularly large, with around 40,000 lines of code.</p>
<h2 id="other">Other</h2>
<ul>
<li>tpch: While the framework&rsquo;s code appears to support tpch, it proved unusable during practical tests, likely due to incomplete implementation and thus excluded from the README.</li>
<li>Referring to future work mentioned in chapter nine of the paper, especially &ldquo;generating load to match production data distribution,&rdquo; this remains unimplemented, as seen in the codebase.</li>
</ul>
]]></content:encoded>
    </item>
  </channel>
</rss>
