IometerによるディスクI/Oパフォーマンス確認

オペレーティングシステム: すべての 32-bit MS Windows (95/98/NT/2000/XP),
MacOSX, Linux, その他, SunOS/Solaris, Windows NT/2000, Windows XP
Iometer プロジェクト日本語トップページ – SourceForge.JP
Iometer Project

Windows32bit版
http://sourceforge.jp/projects/sfnet_iometer/downloads/iometer-devel/1.1.0-rc1/iometer-1.1.0-rc1-win32.i386-bin.zip/

Windows64bit版
http://sourceforge.jp/projects/sfnet_iometer/downloads/iometer-devel/1.1.0-rc1/iometer-1.1.0-rc1-win64.x86_64-bin.zip/

Linux版
http://sourceforge.jp/projects/sfnet_iometer/downloads/iometer-devel/1.1.0-rc1/iometer-1.1.0-rc1-src.tar.bz2/

以前はIntelのサイトからダウンロード出来たが、現在こちらでダウンロード出来るようです。
インテルは既に開発をやめて、OSDLに提供されたようです。
このツールを利用していたのはベンダーに勤めていた時なので、認識していませんでした。

——————————-
It was originally developed by the Intel Corporation and announced at
the Intel Developers Forum (IDF) on February 17, 1998 – since then it
got wide spread within the industry.

Meanwhile Intel has discontinued to work on Iometer and it was given to the
Open Source Development Lab (OSDL). In November 2001, a project was
registered at SourceForge.net and an initial drop was provided.
——————————-

Windows版をダウンロードして展開
http://sourceforge.jp/projects/sfnet_iometer/downloads/iometer-devel/1.1.0-rc1/iometer-1.1.0-rc1-win32.i386-bin.zip/

※デスクトップなどの日本語のパスがあるフォルダーに置いたら起動時に
エラーが表示されたので日本語が無いパスに移動した。

実行すると以下のような管理画面とコンソールが表示される。
コンソール

※こちらで、サービス起動してPortリッスンして管理画面などのGUIへサービスを提供しているのかな。

管理画面

Worker
iometerを動作させるWindows上で認識できるCPU数と同じだけ表示される。(追加可)

Targets
テスト対象のロジカルドライブを選択(×)

Maximum Disk Size
Sectors単位で指定。指定しない場合、ハードディスクの空き容量すべてが使用される。
512byte/Sector
iobw.tst(4.76 GB、5,120,000,000 バイト)のテストファイルが自動作成される。
ストレステスト実行後自動で削除されません。

セクターの確認(fsutil fsinfo ntfsinfo C:)
sector
今回は、1GBのファイルでテスト(2000000 Sector)で検証。

# of Outstanding I/Os
Queue Depth:ストレージの単純性能値を計るにはDefault(1)で良さそう。

Starting Disk Sector
使用する場合は、windowsのコマンド(fsutil fsinfo ntfsinfo C:)
によって計算するそうだが、今回はDefaultのまま利用。

Network Targets
今回はローカルなので使用しません。

Access Specifications
こちらにストレステストケースを定義します。
Assigned Access Specifications
定義したテストケースが順番に実行され、テストケースは編集する事が可能です。

カスタマイズ
読み・書き込み、Worker、ブロックサイズ(512B:1KB:2KB:4KB:8KB:16KB:32KB:64KB)

Results Display
ストレステストの結果サマリーを確認。

Test Setup
Run Time
Assigned Access Specificationsで定義した1つのテストケースでサンプリング対象とする実行時間
Ramp Up Time
ストレステストケース実行の事前準備時間

全てのWorkerに設定を入れたらテストを実行してみる。
※実行すると結果を保存する為のCSVファイル(results.csv)を保存する場所を聞かれるので、
適当に場所を選んで保存を選択すると実行開始される。

ファイルが作成されている。(テスト後にマニュアル削除)

実行結果をresultタブでも見る事が出来ます。

CSVファイル(results.csv)の中には詳細の数値データが記録されている。

参考
ベンチマーク:Iometerの設定方法・使用方法、ストレージパフォーマンステスト


TOPコマンドでパフォーマンスを確認する事で問題ないのですが、
少しだけビジュアライズされてキーボードやマウスで簡単に操作出来るように
なっているHTOPでパフォーマンス確認をより身近にする事で気付ける事も
あるかもしれません。

ダウンロード

[root@colinux htop]# wget http://citylan.dl.sourceforge.net/project/htop/htop/0.8.3/htop-0.8.3.tar.gz
–2012-06-15 09:58:08– http://citylan.dl.sourceforge.net/project/htop/htop/0.8.3/htop-0.8.3.tar.gz
citylan.dl.sourceforge.net をDNSに問いあわせています… 212.118.44.106, 2a03:1800:1:7::2
citylan.dl.sourceforge.net|212.118.44.106|:80 に接続しています… 接続しました。
HTTP による接続要求を送信しました、応答を待っています… 200 OK
長さ: 428061 (418K) [application/x-gzip]
`htop-0.8.3.tar.gz’ に保存中

100%[====================================================================================>] 428,061 71.5K/s 時間 5.9s

2012-06-15 09:58:15 (71.5 KB/s) – `htop-0.8.3.tar.gz’ へ保存完了 [428061/428061]

[root@colinux htop]#

展開

[root@colinux htop]# tar xzvf htop-0.8.3.tar.gz
htop-0.8.3/
htop-0.8.3/Makefile.am
htop-0.8.3/ClockMeter.h
htop-0.8.3/depcomp
htop-0.8.3/Meter.c
htop-0.8.3/htop.1.in
htop-0.8.3/SignalItem.c
htop-0.8.3/plpa-1.1/
htop-0.8.3/plpa-1.1/Makefile.am
htop-0.8.3/plpa-1.1/src/
htop-0.8.3/plpa-1.1/src/Makefile.am
htop-0.8.3/plpa-1.1/src/plpa.h.in
htop-0.8.3/plpa-1.1/src/plpa_dispatch.c
[…省略]
htop-0.8.3/acinclude.m4
htop-0.8.3/Object.c
htop-0.8.3/htop.c
htop-0.8.3/autogen.sh
htop-0.8.3/AvailableMetersPanel.c
[root@colinux htop]#

インストール [configure -> make -> make install]

[root@colinux htop-0.8.3]# ./configure
checking for a BSD-compatible install… /usr/bin/install -c
checking whether build environment is sane… yes
checking for a thread-safe mkdir -p… /bin/mkdir -p
checking for gawk… gawk
checking whether make sets $(MAKE)… yes
checking for gcc… gcc
checking for C compiler default output file name… a.out
checking whether the C compiler works… yes
checking whether we are cross compiling… no
checking for suffix of executables…
checking for suffix of object files… o
checking whether we are using the GNU C compiler… yes
[…省略]
checking for unistd.h… (cached) yes
checking curses.h usability… no
checking curses.h presence… no
checking for curses.h… no
configure: error: missing headers: curses.h
[root@colinux htop-0.8.3]#

configureでエラーになったので必要なパッケージをインストール
エラー内容:configure: error: missing headers: curses.h

[root@colinux htop-0.8.3]# yum install ncurses-devel
fedora 100% |=========================| 2.1 kB 00:00
updates 100% |=========================| 2.3 kB 00:00
Setting up Install Process
Parsing package install arguments

今回は無事にconfigureが完了したので、
makeとmake installしてインストールを完了。

configure: creating ./config.status
config.status: creating plpa-1.1/Makefile
config.status: creating plpa-1.1/src/Makefile
config.status: creating Makefile
config.status: creating htop.1
config.status: creating config.h
config.status: config.h is unchanged
config.status: creating plpa-1.1/src/plpa_config.h
config.status: creating plpa-1.1/src/plpa.h
config.status: executing depfiles commands
[root@colinux htop-0.8.3]#
[root@colinux htop-0.8.3]# make
[…省略]
[root@colinux htop-0.8.3]# make install
[…省略]

htopを起動してみる。
パスを指定しなければ以下のパスにインストールされている。

[root@colinux htop-0.8.3]# whereis htop
htop: /usr/local/bin/htop
[root@colinux htop-0.8.3]#
[root@colinux htop-0.8.3]# htop

起動後はF1~F10キーでNICEやTREEなども操作出来る。

通常起動後

htop

htop


memcached は、データとオブジェクトをメモリ内にキャッシュすることで、
データベースなどからデータを頻繁に取りにいくことを減らしてパフォーマンスを改善させたり、
セッションをmemcached上に載せる事で、高速なセッション管理を行ったりする事が出来る。

The latest stable memcached release is
v1.4.13
memcached.org

Free & open source, high-performance, distributed memory object caching system,
generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

libeventのインストール

[root@ Sun May 27]# yum install libevent libevent-devel
Loaded plugins: fastestmirror, priorities, security, update-motd
Loading mirror speeds from cached hostfile
* amzn-main: packages.ap-northeast-1.amazonaws.com
* amzn-updates: packages.ap-northeast-1.amazonaws.com
amzn-main | 2.1 kB 00:00
amzn-updates | 2.3 kB 00:00
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package libevent.x86_64 0:1.4.13-1.6.amzn1 will be installed
—> Package libevent-devel.x86_64 0:1.4.13-1.6.amzn1 will be installed
–> Finished Dependency Resolution

省略…
Dependencies ResolvedDownloading Packages:
(1/2): libevent-1.4.13-1.6.amzn1.x86_64.rpm | 114 kB 00:00
(2/2): libevent-devel-1.4.13-1.6.amzn1.x86_64.rpm | 386 kB 00:00

MEMCACHEDインストール

[root@ Sun May 27]# wget http://memcached.googlecode.com/files/memcached-1.4.13.tar.gz
–2012-05-27 17:56:05– http://memcached.googlecode.com/files/memcached-1.4.13.tar.gz
Resolving memcached.googlecode.com… 72.14.203.82
Connecting to memcached.googlecode.com|72.14.203.82|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 320751 (313K) [application/x-gzip]
Saving to: “memcached-1.4.13.tar.gz”

100%[==========================================================================>] 320,751 1.37M/s in 0.2s

2012-05-27 17:56:06 (1.37 MB/s) – “memcached-1.4.13.tar.gz” saved [320751/320751]

[root@ Sun May 27]#

[root@ Sun May 27]# tar zxf memcached-1.4.13.tar.gz
[root@ Sun May 27]# ls -l
total 320
drwxr-xr-x 6 1000 1000 4096 Feb 3 06:24 memcached-1.4.13
-rw-r–r– 1 root root 320751 Feb 3 06:27 memcached-1.4.13.tar.gz
[root@ Sun May 27]# cd memcached-1.4.13
[root@ Sun May 27]# ./configure
checking build system type… x86_64-unknown-linux-gnu
checking host system type… x86_64-unknown-linux-gnu
checking target system type… x86_64-unknown-linux-gnu
checking for a BSD-compatible install… /usr/bin/install -c
checking whether build environment is sane… yes
checking for a thread-safe mkdir -p… /bin/mkdir -p
checking for gawk… gawk
checking whether make sets $(MAKE)… yes
checking for gcc… gcc
checking whether the C compiler works… yes
checking for C compiler default output file name… a.out
checking for suffix of executables…
checking whether we are cross compiling… no
checking for suffix of object files… o
checking whether we are using the GNU C compiler… yes
checking whether gcc accepts -g… yes

[省略]……………………………………..

[root@ Sun May 27]# make
make all-recursive
make[1]: Entering directory `/home/ec2-user/memcached/memcached-1.4.13′
Making all in doc
make[2]: Entering directory `/home/ec2-user/memcached/memcached-1.4.13/doc’
make all-am
make[3]: Entering directory `/home/ec2-user/memcached/memcached-1.4.13/doc’
make[3]: Nothing to be done for `all-am’.
make[3]: Leaving directory `/home/ec2-user/memcached/memcached-1.4.13/doc’
make[2]: Leaving directory `/home/ec2-user/memcached/memcached-1.4.13/doc’
make[2]: Entering directory `/home/ec2-user/memcached/memcached-1.4.13′
gcc -std=gnu99 -DHAVE_CONFIG_H -I. -DNDEBUG -g -O2 -pthread -Wall -Werror -pedantic
-Wmissing-prototypes -Wmissing-declarations -Wredundant -decls -fno-strict-aliasing -MT memcached-memcached.o
-MD -MP -MF .deps/memcached-memcached.Tpo -c -o memcached-memcached.o `test -f ‘memcached.c’ || echo ‘./’`memcached.c

[root@ Sun May 27]# make install
make install-recursive
make[1]: Entering directory `/home/ec2-user/memcached/memcached-1.4.13′
Making install in doc
make[2]: Entering directory `/home/ec2-user/memcached/memcached-1.4.13/doc’
make install-am
make[3]: Entering directory `/home/ec2-user/memcached/memcached-1.4.13/doc’
make[4]: Entering directory `/home/ec2-user/memcached/memcached-1.4.13/doc’
make[4]: Nothing to be done for `install-exec-am’.
test -z “/usr/local/share/man/man1” || /bin/mkdir -p “/usr/local/share/man/man1”
/usr/bin/install -c -m 644 memcached.1 ‘/usr/local/share/man/man1′
make[4]: Leaving directory `/home/ec2-user/memcached/memcached-1.4.13/doc’
make[3]: Leaving directory `/home/ec2-user/memcached/memcached-1.4.13/doc’
make[2]: Leaving directory `/home/ec2-user/memcached/memcached-1.4.13/doc’
make[2]: Entering directory `/home/ec2-user/memcached/memcached-1.4.13′
make[3]: Entering directory `/home/ec2-user/memcached/memcached-1.4.13′
test -z “/usr/local/bin” || /bin/mkdir -p “/usr/local/bin”
/usr/bin/install -c memcached ‘/usr/local/bin’
test -z “/usr/local/include/memcached” || /bin/mkdir -p “/usr/local/include/memcached”
/usr/bin/install -c -m 644 protocol_binary.h ‘/usr/local/include/memcached’
make[3]: Leaving directory `/home/ec2-user/memcached/memcached-1.4.13′
make[2]: Leaving directory `/home/ec2-user/memcached/memcached-1.4.13′
make[1]: Leaving directory `/home/ec2-user/memcached/memcached-1.4.13′
[root@ Sun May 27]#

[root@ Sun May 27]# whereis memcached
memcached: /usr/local/bin/memcached
[root@ Sun May 27]#

基本起動確認

[ec2-user@ Sun May 27]$ /usr/local/bin/memcached -p 11211 -m 10m -vv
slab class 1: chunk size 96 perslab 10922
slab class 2: chunk size 120 perslab 8738
slab class 3: chunk size 152 perslab 6898
slab class 4: chunk size 192 perslab 5461
slab class 5: chunk size 240 perslab 4369
slab class 6: chunk size 304 perslab 3449
slab class 7: chunk size 384 perslab 2730
slab class 8: chunk size 480 perslab 2184
slab class 9: chunk size 600 perslab 1747
slab class 10: chunk size 752 perslab 1394
slab class 11: chunk size 944 perslab 1110
slab class 12: chunk size 1184 perslab 885
slab class 13: chunk size 1480 perslab 708
slab class 14: chunk size 1856 perslab 564
slab class 15: chunk size 2320 perslab 451
slab class 16: chunk size 2904 perslab 361
slab class 17: chunk size 3632 perslab 288
slab class 18: chunk size 4544 perslab 230
slab class 19: chunk size 5680 perslab 184
slab class 20: chunk size 7104 perslab 147
slab class 21: chunk size 8880 perslab 118
slab class 22: chunk size 11104 perslab 94
slab class 23: chunk size 13880 perslab 75
slab class 24: chunk size 17352 perslab 60
slab class 25: chunk size 21696 perslab 48
slab class 26: chunk size 27120 perslab 38
slab class 27: chunk size 33904 perslab 30
slab class 28: chunk size 42384 perslab 24
slab class 29: chunk size 52984 perslab 19
slab class 30: chunk size 66232 perslab 15
slab class 31: chunk size 82792 perslab 12
slab class 32: chunk size 103496 perslab 10
slab class 33: chunk size 129376 perslab 8
slab class 34: chunk size 161720 perslab 6
slab class 35: chunk size 202152 perslab 5
slab class 36: chunk size 252696 perslab 4
slab class 37: chunk size 315872 perslab 3
slab class 38: chunk size 394840 perslab 2
slab class 39: chunk size 493552 perslab 2
slab class 40: chunk size 616944 perslab 1
slab class 41: chunk size 771184 perslab 1
slab class 42: chunk size 1048576 perslab 1
<26 server listening (auto-negotiate) <27 server listening (auto-negotiate) <28 send buffer was 229376, now 268435456 <29 send buffer was 229376, now 268435456 <28 server listening (udp) <29 server listening (udp)

バックグラウンド起動し動作検証

デーモンとしてバックグラウンド起動
[ec2-user@ Sun May 27]$ /usr/local/bin/memcached -p 11211 -m 10m -d
[ec2-user@ Sun May 27]$ ps -ef | grep mem
ec2-user 18639 1 0 18:04 ? 00:00:00 /usr/local/bin/memcached -p 11211 -m 10m -d
ec2-user 18646 17197 0 18:04 pts/0 00:00:00 grep mem
[ec2-user@ Sun May 27]$

[ec2-user@ Sun May 27]$ /usr/local/bin/memcached -h
memcached 1.4.13
-p TCP port number to listen on (default: 11211)
-U UDP port number to listen on (default: 11211, 0 is off)
-s UNIX socket path to listen on (disables network support)
-a access mask for UNIX socket, in octal (default: 0700)
-l interface to listen on (default: INADDR_ANY, all addresses)
may be specified as host:port. If you don’t specify
a port number, the value you specified with -p or -U is
used. You may specify multiple addresses separated by comma
or by using -l multiple times
-d run as a daemon
-r maximize core file limit
-u assume identity of (only when run as root)
-m max memory to use for items in megabytes (default: 64 MB)
-M return error on memory exhausted (rather than removing items)
-c max simultaneous connections (default: 1024)
-k lock down all paged memory. Note that there is a
limit on how much memory you may lock. Trying to
allocate more than that would fail, so be sure you
set the limit correctly for the user you started
the daemon with (not for -u user;
under sh this is done with ‘ulimit -S -l NUM_KB’).
-v verbose (print errors/warnings while in event loop)
-vv very verbose (also print client commands/reponses)
-vvv extremely verbose (also print internal state transitions)
-h print this help and exit
-i print memcached and libevent license
-P save PID in , only used with -d option
-f chunk size growth factor (default: 1.25)
-n minimum space allocated for key+value+flags (default: 48)
-L Try to use large memory pages (if available). Increasing
the memory page size could reduce the number of TLB misses
and improve the performance. In order to get large pages
from the OS, memcached will allocate the total item-cache
in one large chunk.
-D Use as the delimiter between key prefixes and IDs.
This is used for per-prefix stats reporting. The default is
“:” (colon). If this option is specified, stats collection
is turned on automatically; if not, then it may be turned on
by sending the “stats detail on” command to the server.
-t number of threads to use (default: 4)
-R Maximum number of requests per event, limits the number of
requests process for a given connection to prevent
starvation (default: 20)
-C Disable use of CAS
-b Set the backlog queue limit (default: 1024)
-B Binding protocol – one of ascii, binary, or auto (default)
-I Override the size of each slab page. Adjusts max item size
(default: 1mb, min: 1k, max: 128m)
-o Comma separated list of extended or experimental options
– (EXPERIMENTAL) maxconns_fast: immediately close new
connections if over maxconns limit
– hashpower: An integer multiplier for how large the hash
table should be. Can be grown at runtime if not big enough.
Set this based on “STAT hash_power_level” before a
restart.
[ec2-user@ Sun May 27]$

telnet経由でデータの入力などの基本動作検証

[ec2-user@ Sun May 27]$ telnet localhost 11211
Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.
stats
STAT pid 18639
STAT uptime 1139
STAT time 1338110621
STAT version 1.4.13
STAT libevent 1.4.13-stable
STAT pointer_size 64
STAT rusage_user 0.015997
STAT rusage_system 0.015997
STAT curr_connections 10
STAT total_connections 11

set key01 0 0 5
00001
set key02 0 0 5
00002
set key03 0 0 5
00003

memcached

memcached


MS SQLやOracleにもProfile機能を利用して、パフォーマンスや問題確認を行う
機能がありますが、OSSのMYSQLにも同じようにProfile機能が存在してます。
本日は、Profile機能の簡単な確認。

===============================================================

mysql> SHOW VARIABLES LIKE 'profil%';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| profiling | OFF |
| profiling_history_size | 15 |
+------------------------+-------+
2 rows in set (0.00 sec)

mysql> SET profiling=1;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW VARIABLES LIKE 'profil%';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| profiling | ON |
| profiling_history_size | 15 |
+------------------------+-------+
2 rows in set (0.00 sec)

mysql>

===============================================================

profiling config


mysql> select * from Y2008 limit 1;
+----+----------+
| id | comment |
+----+----------+
| 1 | comment1 |
+----+----------+
1 row in set (0.00 sec)

mysql> SHOW PROFILES;
+----------+------------+--------------------------------------+
| Query_ID | Duration | Query |
+----------+------------+--------------------------------------+
| 1 | 0.02000000 | select * from Y2008 |
| 2 | 0.02000100 | SHOW VARIABLES LIKE 'tmp_table_size' |
| 3 | 0.01000000 | SHOW VARIABLES like 'profile%' |
| 4 | 0.02000100 | SHOW VARIABLES like 'profi%' |
| 5 | 0.01000000 | SHOW VARIABLES LIKE 'profile%' |
| 6 | 0.00000000 | SHOW VARIABLES LIKE 'profile%' |
| 7 | 0.01000000 | SHOW VARIABLES LIKE 'profil%' |
| 8 | 0.00000000 | SHOW VARIABLES LIKE 'profil%' |
| 9 | 0.00000000 | select * from Y2008 limit 1 |
+----------+------------+--------------------------------------+
9 rows in set (0.01 sec)

mysql>

プロファイル履歴

mysql> SHOW PROFILE;
+——————–+———-+
| Status | Duration |
+——————–+———-+
| starting | 0.000000 |
| Opening tables | 0.000000 |
| System lock | 0.000000 |
| Table lock | 0.000000 |
| init | 0.000000 |
| optimizing | 0.000000 |
| statistics | 0.000000 |
| preparing | 0.000000 |
| executing | 0.000000 |
| Sending data | 0.000000 |
| end | 0.000000 |
| query end | 0.000000 |
| freeing items | 0.000000 |
| logging slow query | 0.000000 |
| cleaning up | 0.000000 |
+——————–+———-+
15 rows in set (0.00 sec)

mysql>

profile_2

profile_3


StatusとDurationを表示


mysql> SHOW PROFILE SOURCE;
+--------------------+----------+-----------------------+--------------+-------------+
| Status | Duration | Source_function | Source_file | Source_line |
+--------------------+----------+-----------------------+--------------+-------------+
| starting | 0.000000 | NULL | NULL |NULL |
| query end | 0.000000 | mysql_execute_command | sql_parse.cc |4799 |
| freeing items | 0.000000 | mysql_parse | sql_parse.cc |5805 |
| logging slow query | 0.000000 | log_slow_statement | sql_parse.cc |1608 |
| cleaning up | 0.000000 | dispatch_command | sql_parse.cc |1575 |
+--------------------+----------+-----------------------+--------------+-------------+
5 rows in set (0.01 sec)

mysql> SHOW PROFILE BLOCK IO;
+--------------------+----------+--------------+---------------+
| Status | Duration | Block_ops_in | Block_ops_out |
+--------------------+----------+--------------+---------------+
| starting | 0.010000 | 0 | 0 |
| Opening tables | 0.000000 | 0 | 0 |
| query end | 0.000000 | 0 | 0 |
| freeing items | 0.000000 | 0 | 0 |
| logging slow query | 0.000000 | 0 | 0 |
| cleaning up | 0.000000 | 0 | 0 |
+--------------------+----------+--------------+---------------+
6 rows in set (0.00 sec)
mysql>

mysql> SHOW PROFILE CONTEXT SWITCHES;
+--------------------+----------+-------------------+---------------------+
| Status | Duration | Context_voluntary | Context_involuntary |
+--------------------+----------+-------------------+---------------------+
| starting | 0.000000 | 0 | 0 |
| freeing items | 0.000000 | 0 | 1 |
| logging slow query | 0.000000 | 0 | 0 |
| cleaning up | 0.000000 | 0 | 0 |
+--------------------+----------+-------------------+---------------------+
4 rows in set (0.00 sec)

mysql>

mysql> SHOW PROFILE CPU;
+--------------------+----------+----------+------------+
| Status | Duration | CPU_user | CPU_system |
+--------------------+----------+----------+------------+
| starting | 0.000000 | 0.000000 | 0.000000 |
| freeing items | 0.000000 | 0.000000 | 0.000000 |
| logging slow query | 0.000000 | 0.000000 | 0.000000 |
| cleaning up | 0.000000 | 0.000000 | 0.000000 |
+--------------------+----------+----------+------------+
4 rows in set (0.00 sec)

mysql>

mysql> SHOW PROFILE IPC;
+--------------------+----------+---------------+-------------------+
| Status | Duration | Messages_sent | Messages_received |
+--------------------+----------+---------------+-------------------+
| starting | 0.000000 | 0 | 0 |
| freeing items | 0.000000 | 0 | 0 |
| logging slow query | 0.000000 | 0 | 0 |
| cleaning up | 0.000000 | 0 | 0 |
+--------------------+----------+---------------+-------------------+
4 rows in set (0.01 sec)

mysql>

mysql> SHOW PROFILE MEMORY;
+--------------------+----------+
| Status | Duration |
+--------------------+----------+
| starting | 0.000000 |
| freeing items | 0.000000 |
| logging slow query | 0.000000 |
| cleaning up | 0.000000 |
+--------------------+----------+
4 rows in set (0.00 sec)

mysql>

mysql> SHOW PROFILE PAGE FAULTS;
+--------------------+----------+-------------------+-------------------+
| Status | Duration | Page_faults_major | Page_faults_minor |
+--------------------+----------+-------------------+-------------------+
| starting | 0.000000 | 0 | 0 |
| freeing items | 0.000000 | 0 | 0 |
| logging slow query | 0.000000 | 0 | 0 |
| cleaning up | 0.000000 | 0 | 0 |
+--------------------+----------+-------------------+-------------------+
4 rows in set (0.00 sec)

mysql>

mysql> SHOW PROFILE SWAPS;
+--------------------+----------+-------+
| Status | Duration | Swaps |
+--------------------+----------+-------+
| starting | 0.000000 | 0 |
| freeing items | 0.000000 | 0 |
| logging slow query | 0.000000 | 0 |
| cleaning up | 0.000000 | 0 |
+--------------------+----------+-------+
4 rows in set (0.00 sec)

mysql>

======================================================
過去に取得した値を確認
======================================================


mysql> SHOW PROFILES;
+----------+------------+--------------------------------------+
| Query_ID | Duration | Query |
+----------+------------+--------------------------------------+
| 6 | 0.00000000 | SHOW VARIABLES LIKE 'profile%' |
| 7 | 0.01000000 | SHOW VARIABLES LIKE 'profil%' |
| 8 | 0.00000000 | SHOW VARIABLES LIKE 'profil%' |
| 9 | 0.00000000 | select * from Y2008 limit 1 |
| 10 | 0.00000000 | select * from Y2008 limit 1 |
| 11 | 0.00000000 | show processlist |
| 12 | 0.83001300 | SHOW LOCAL STATUS |
| 13 | 0.86001300 | SHOW LOCAL STATUS |
| 14 | 0.01000000 | SHOW VARIABLES LIKE 'tmp_table_size' |
| 15 | 0.00000000 | SET tmp_table_size=64*1024*1024 |
| 16 | 0.00000000 | SHOW VARIABLES LIKE 'tmp_table_size' |
| 17 | 0.80001200 | SHOW LOCAL STATUS |
| 18 | 0.89001400 | SHOW LOCAL STATUS |
| 19 | 0.01000000 | SET tmp_table_size=16*1024*1024 |
| 20 | 0.00000000 | SHOW PROFILE CONTEXT SWITCHS |
+----------+------------+--------------------------------------+
15 rows in set (0.00 sec)

mysql>

mysql> SHOW PROFILE SOURCE FOR QUERY 20;
+--------------------+----------+--------------------+--------------+-------------+
| Status | Duration | Source_function | Source_file | Source_line |
+--------------------+----------+--------------------+--------------+-------------+
| starting | 0.000000 | NULL | NULL | NULL |
| freeing items | 0.000000 | mysql_parse | sql_parse.cc | 5805 |
| logging slow query | 0.000000 | log_slow_statement | sql_parse.cc | 1608 |
| cleaning up | 0.000000 | dispatch_command | sql_parse.cc | 1575 |
+--------------------+----------+--------------------+--------------+-------------+
4 rows in set (0.00 sec)

mysql>

profile_4


mysql> SET profiling=0;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW VARIABLES LIKE 'profil%';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| profiling | OFF |
| profiling_history_size | 15 |
+------------------------+-------+
2 rows in set (0.00 sec)

mysql>


12.5.5.33. SHOW PROFILES Syntax


PHPのパフォーマンスを簡単に手に入れたいのであれば,一度検討してみるのも良いかも。

Zendが無償で提供するPHPコードの最適化モジュール

Zend Optimizerは、PHPコードの最適化を行ない実行速度を数%から数十%まで高速化します。
また、PHPコードのセキュリティソリューション Zend Guard (Zend Encoder/ Zend SafeGuard Suite の後継製品としてリリース予定)がエンコード(変換した)コードの実行にも使用します。
モジュールローディング方式なので、PHPをコンパイルすることなく導入できます。