Dynimize Quickstart Tutorial

Duration: 10 min

Level: Beginner

 

This tutorial will show you how to install Dynimize. We'll then use it to optimize a live MySQL process that's been running the Sysbench OLTP benchmark, obtaining a 46% increase in performance by applying Dynimize.

 

Part 1:  Quickstart

 

Here's a quick overview of how to use Dynimize.

To install Dynimize, run the following commands.

wget https://dynimize.com/install -O install
wget https://dynimizecloud.com/install.sha256 -O install.sha256
sha256sum -c install.sha256; if [ $? -eq 0 ]; then sudo bash ./install -d; fi

 

Use your access token to start a subscription license for your host.

$ sudo dyni -license=start -token=<your-access-token>

 

To start Dynimize, run

$ sudo dyni -start

 

To check the status of Dynimize and any optimization targets, run:

$ sudo dyni -status

 

Once a target process has been fully optimized, the above command will report:

Dynimize is running
mysqld, pid: 21091, dynimized

 

It could take anywhere from 30 to 300s of CPU intensive activity from the target process before Dynimize has completed profiling and optimizing that process.

Deciding which applications to target can be done by editing the list of supported target exes in /etc/dyni.conf under the [exeList] section.

 

To stop Dynimize, run:

$ sudo dyni -stop

 

To stop the subscription license for this host, run:

$sudo dyni -license=stop -token=<your-access-token>

 

Follow this tutorial for help measuring the performance impact.

 

Part 2:   Benchmarking with Dynimize

 

In the remainder of this tutorial we'll demonstrate how to benchmark MySQL using the Sysbench OLTP benchmark, and then improve on the benchmark results by installing and running Dynimize alongside MySQL. We try to keep things as simple as possible, and so by no means is this meant to demonstrate the most realistic or optimal way to benchmark MySQL with Sysbench, or accurately measure the improvements Dynimize can achieve. This tutorial can be completed with any version of MySQL, MariaDB, or Percona Server, and it is assumed that one of these is already installed.

Note that the benchmark is run using a CPU bound setup, with --oltp-read-only=on so that the IO subsystem is not involved, and making sure the workload fits into RAM. This example was run on a cloud based VPS from OVH, with 2 vCPUs (2.4 Ghz Haswell), with 8 GB ram, and a 40 GB SSD. You can recreate this exact VM on OVH's public cloud by selecting the VPS-SSD-3 server option in their Beauharnois data center. We used Ubuntu 16.04.2 LTS with MySQL 5.7.18, and Sysbench 0.4.12. Note that Sysbench 0.4 is used in this tutorial because it can easily be installed from most Linux repositories. Note that Dynimize speedups can be more pronounced when running on KVM hypervisors, as is the case here.

 

1. Install Sysbench

apt-get based install:

$ sudo apt-get install sysbench

 

OR

yum based install:

$ sudo yum install sysbench

 

2. Run sysbench

In the following commands, make sure to replace user and password with something appropriate. Here we use the database name testDB.

Lets start off with a fresh MySQL process:

$ sudo service mysql restart

 

Load a table for the Sysbench OLTP workload. Make sure to replace user and password as appropriate:

$ mysql -u user --password=password -e "DROP DATABASE testDB;"
$ mysql -u user --password=password -e "CREATE DATABASE testDB;"
$ sysbench --test=oltp --oltp-table-size=1000000 --mysql-db=testDB --mysql-user=user --mysql-password='password' prepare

 

Perform a warm-up run:

$ sysbench --test=oltp --oltp-table-size=1000000 --mysql-db=testDB --mysql-user=user --mysql-password='password' --max-time=120 --oltp-read-only=on --max-requests=0 --num-threads=8 run

 

Perform a measurement run (command is the same as warm-up):

$ sysbench --test=oltp --oltp-table-size=1000000 --mysql-db=testDB --mysql-user=user --mysql-password='password' --max-time=120 --oltp-read-only=on --max-requests=0 --num-threads=8 run

 

These runs will produce results in the following format:

OLTP test statistics:
queries performed:
read: 1203062
write: 0
other: 171866
total: 1374928
transactions: 85933 (1432.12 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 1203062 (20049.73 per sec.)
other operations: 171866 (2864.25 per sec.)

Test execution summary:
total time: 60.0039s
total number of events: 85933
total time taken by event execution: 479.6911
per-request statistics:
min: 1.19ms
avg: 5.58ms
max: 41.07ms
approx. 95 percentile: 7.85ms

Threads fairness:
events (avg/stddev): 10741.6250/233.97
execution time (avg/stddev): 59.9614/0.00

 

In this case we can see transactions per second of 1432.12 as highlighted above.

 

3. Repeat with Dynimize

Let's repeat that with Dynimize running. First install Dynimize and start a host license if you haven't already.

If you haven't already done so, install Dynimize:

wget https://dynimize.com/install -O install
wget https://dynimizecloud.com/install.sha256 -O install.sha256
sha256sum -c install.sha256; if [ $? -eq 0 ]; then sudo bash ./install -d; fi

 

If you haven't already started a subscription license for your host then use your access token to start one :

$sudo dyni -license=start -token=<your-access-token>

 

Now start Dynimize:

$ sudo dyni -start

 

Perform another warmup run to get the mysqld process in the "dynimized" state:

$ sysbench --test=oltp --oltp-table-size=1000000 --mysql-db=testDB --mysql-user=user --mysql-password='password' --max-time=120 --oltp-read-only=on --max-requests=0 --num-threads=8 run

 

After the warmup make sure mysqld is dynimized:

$ sudo dyni -status
Dynimize is running
mysqld, pid: 25072, dynimized

 

If the mysqld process is not yet dynimized then repeatedly run the warm-up followed by sudo dyni -status until mysqld shows up as dynimized.

 

Now that mysqld is dynimized, let's measure its performance again:

$ sysbench --test=oltp --oltp-table-size=1000000 --mysql-db=testDB --mysql-user=user --mysql-password='password' --max-time=120 --oltp-read-only=on --max-requests=0 --num-threads=8 run

 

Which will output the following:

OLTP test statistics:
queries performed:
read: 1759352
write: 0
other: 251336
total: 2010688
transactions: 125668 (2094.36 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 1759352 (29321.06 per sec.)
other operations: 251336 (4188.72 per sec.)

Test execution summary:
total time: 60.0030s
total number of events: 125668
total time taken by event execution: 479.5530
per-request statistics:
min: 0.77ms
avg: 3.82ms
max: 492.75ms
approx. 95 percentile: 5.52ms

Threads fairness:
events (avg/stddev): 15708.5000/166.91
execution time (avg/stddev): 59.9441/0.00

 

Here we see transactions per second of 2094.36, which is a 46% speedup from the baseline of 1432.12 tps.

That concludes this tutorial. Happy Dynimizing!


David Yeager is the founder of Dynimize Inc, with over a decade of experience in just-in-time compiler development. He is passionate about computer architectures and software performance, and his mission is to see dynamic compilation and optimization accelerate all workloads (through Dynimize).


COPYRIGHT © DYNIMIZE INC.