as3ap benchmark test
as3ap とは、"An ANSI SQL Standard Scalable and Portable Benchmark for Relational Database Systems" の略称です。ベンチマークの内容については、Jim Gray 編集のThe Benchmark Handbook: For Database and Transaction Processing Systems (Morgan Kaufmann Series in Data Management Systems)に所収されているそうなんですが、すでに絶版でプレミアがついてしまっています。
cvsからas3apのソース一式を落とすと as3ap/dot-net/doc に The Benchmark Handbook - Chapter5.pdf が含まれていて、ANSIのsencod draftということですが内容を見ることが出来ます。ライセンス的に再配布していいのか怪しいので、ここでは直接配りませんが、cvsから落としてみて下さい。
(2006/1/09)
テスト環境のセットアップ
関連ファイルの準備
Sourceforge上のFirebirdプロジェクトのダウンロードエリアに、firebird-benchmarksとしてファイルが置いてあります。しかし、これはベンチマーク用のデータのみとなっています。
http://sourceforge.net/project/showfiles.php?group_id=9028&package_id=73289
http://prdownloads.sourceforge.net/firebird/as3ap-data-40mb.tgz?download
上記リンクから as3ap-data-40m.tgz をダウンロードしておいて下さい。
as3apベンチマーク本体は、cvsからダウンロードしなくてはなりません。
Windowsからの場合は、TortoiseCVSがお勧めです。下記のWebサイトで配布されているので利用してみて下さい。多国語に対応していて、日本語での表示も組み込まれています。sshの対応も問題なく、sourceforgeへのssh接続も行えます。
http://www.tortoisecvs.org/
tortoisecvsでのfirebird-benchmarksのダウンロードは実に簡単です、インストール後に適当なディレトリをエクスプローラーで開いて、そこで右クリックのコンテクストメニューから「cvsチェックアウト」を実行すると以下のダイアログが出るので、必要な要素を埋めて「OK」ボタンを押すだけです。パスワードを入れろと言われますが、anonymous接続の時は、パスワードは空にしておくのは言うまでもありません。

Java2SDK
Java2SDKの1.4.2を使用しました。
http://java.sun.com/j2se/corejava/index.jsp
Java2SDKについては、上記からダウンロードして下さい。
ここでは、Windows版の j2sdk-1_4_2_10-windows-i586-p.exe をダウンロードして、インストールしました。インストール先は、c:\bin\j2sdk1.4.2_10 です。
その後、環境変数に以下の設定を行いました。
JAVA_HOME=C:\bin\j2sdk1.4.2_10
CLASSPATH=%JAVA_HOME%\lib\jaybird-full-2.0.1.jar
Jaybird
Javaから実行するベンチマークなので、Jaybirdが必要となります。落としたソースに入っているのですが、どうもこれはj2se 1.3対応のもの(?)らしく、うまく動作しないので最新版の2.0.1をSourceForgeから落として下さい。
http://sourceforge.net/project/showfiles.php?group_id=9028&package_id=44761
Jaybird 2.0.1は、j2se 1.3, 1.4, 1.5 のそれぞれに対応して別パッケージになっているので、該当するものをダウンロードして下さい。今回は、2.0.1-release-jdk14を使いました。
ダウンロードして、JayBird-2.0.1JDK_1.4.zipを解凍した jaybird-full-2.0.1.jar を、%JAVA_HOME%\lib に配置しておきます。
Firebirdのセットアップ
Firebirdは、Windows版のClassicサーバー 1.5.2を使用しました。
http://sourceforge.net/project/showfiles.php?group_id=9028&package_id=29791
ここから、 Firebird-1.5.2.4731-Win32.exe をダウンロードして、実行して下さい。インストールオプションで、ClassiかSuperかを選べるので今回はClassicを選んでいます。
その他の条件は以下の通りです。
- OS:Windows2000SP4
- CPU:Pentium4 2.4A
- Mem:1GB PC2700DDR
- HDD:WDC WD600AB IDE UDMA-5
as3ap ベンチマークのビルド
さて、準備が整ったところでas3apベンチマークをビルドしてみましょう。antを利用したビルドプロセスになっているので、as3ap\javaディレクトリにあるbuild.batを実行すればよいだけです・・・、うまくビルドできません。
どうも、Jaybird関連のクラスがimport出来ていないようです。build.xmlを以下のように変更しました。67行目からの部分で+がついている行を追加してあります。元々、as3ap\java\lib ディレクトリには、firebirdsql-full.jar が配置されているのですが、これを使うとうまくいかないためj2se 1.4向けのJaybirdと入れ替えてあります。
また、103行目空の部分では、最終的に生成される zip アーカイブに含めるファイル名と、実際に生成されるファイル名が違ってしまっているので junit.jar しか含まれていない zip ファイルが出来てしまうため、ファイル名を合わせるために書き換えた部分です。
--- as3ap/Java/build.xml 13 May 2004 12:53:29 -0000 1.3
+++ as3ap/Java/build.xml 8 Jan 2006 15:09:12 -0000
@@ -67,6 +67,7 @@
<path id="javac.classpath">
<pathelement location="${module.lib}/junit.jar"/>
+ <pathelement location="${module.lib}/firebirdsql-full-2.0.1.jar"/>
</path>
</target>
@@ -103,7 +104,7 @@
<target name="jar" depends="compile">
<mkdir dir="${build.lib}"/>
- <jar jarfile="${build.lib}/firebird_as3ap.jar">
+ <jar jarfile="${build.lib}/firebirdsql_as3ap.jar">
<fileset dir="${build.classes}">
<include name="org/firebirdsql/**"/>
</fileset>
このパッチを適用した後で、再度 build.bat を実行すると問題なく、Firebird_AS3AP-0.1.1Beta.zip が as3ap\java\output\dist ディレクトリに生成されました。
さて、しかしこのままでは実は問題があります。ベンチマークで使用するデータベースの位置や接続ユーザー名等は benchmarkSuite.properties で指定するようになっています。変更しても良さそうなプロパティとデフォルト値は以下の通りです。
dataPath ./as3ap/data-40mb
userName SYSDBA
password masterkey
txIsolation TRANSACTION_REPEATABLE_READ
pooling none
maxConnections 100
userCount 40
recreateTable false
custom.firebird.databasePath c:/database/as3ap.gdb
custom.firebird.type EMBEDDED
このうち、Classicサーバーではローカル接続は使用できないので、localhostを使ったループバックに変更し、custom.firebird.typeをPURE_JAVAに変更しました。ユーザ名とパスワードはお使いのものに変更しておいて下さい。後で、テストデータベースを作成するのにそのユーザーを使ってもらいます。
custom.firebird.databasePath localhost:c:/database/as3ap.gdb
custom.firebird.type PURE_JAVA
上記設定でビルドした Firebird_AS3AP-0.1.1Beta.zip をダウンロードできます。
as3ap ベンチマークの実行
テストデータの作成
さて、いよいよ as3ap ベンチマークを実行してみましょう。まず、Firebird_AS3AP-0.1.1Beta.zip を適当な作業用のディレクトリに展開します。ここでは、c:\temp としました。ここに as3ap ディレクトリを作成し、その中へ先程ダウンロードしておいて、as3ap-data-40m.tgz を解凍しておきます。
次にベンチマーク用のデータを作成します。isqlやIBOConsoleを利用して、先程benchmarkSuite.properties で指定したユーザーを利用して c:\database\as3ap.gdbを作成して下さい。
それでは、コマンドプロンプトで以下のコマンドを実行して下さい。
>java -cp %CLASSPATH%;lib\junit.jar;firebirdsql_as3ap.jar org.firebirdsql.benchmark.LoadDataSuite
Loading file asap.updates
Inserted 1000 rows
...
Inserted 99000 rows
Loading file asap.tiny
Time: 1,238.631
OK (1 tests)
Test execution statistics:
testLoadData - 1 time(s), in 1230549 ms..
すると、c:\temp\as3ap\data-40mb 内のデータを利用してデータベースが初期化されます。今回のテスト環境で大体20分くらいかかりました。結構時間のかかる処理ですので、コーヒーでも飲んでお待ち下さい。
また、今後このデータベースを使ってテストを行うと、再度テストをする際にまた初期化しなくてはならないので、時間を節約するためにコピーを取っておいて使いませるようにしておきます。きちんとバックアップ・リストアしてもいいのですが、これも結構時間のかかる処理なので、テスト用ですからコピーして戻せばよいでしょう。もちろん、毎度 LoadDataSuite を実行しても構いません・・・。
シングルユーザーテスト
さて、それではシングルユーザーモードでベンチマークを取ってみましょう。以下のコマンドをコマンドプロンプトで実行します。
>java -cp %CLASSPATH%;lib\junit.jar;firebirdsql_as3ap.jar org.firebirdsql.benchmark.SingleUserSuite
...
Time: 50.502
OK (70 tests)
Test execution statistics:
testModeTinyRelation - 1 time(s), in 1132 ms..
testTenPctKeyCodeIndex - 1 time(s), in 1302 ms..
testModeTinyFile - 1 time(s), in 300 ms..
testSelect1Clustered - 1 time(s), in 171 ms..
testModeTinyScreen - 1 time(s), in 110 ms..
testTenPctIntIndex - 1 time(s), in 661 ms..
testMode100kFile - 1 time(s), in 831 ms..
testMode1kRelation - 1 time(s), in 140 ms..
testTenPctSignedIndex - 1 time(s), in 711 ms..
testUniquesCodeIndex - 1 time(s), in 921 ms..
testMode1kFile - 1 time(s), in 141 ms..
testTenPctDoubleIndex - 1 time(s), in 931 ms..
testUpdatesDecimIndex - 1 time(s), in 801 ms..
testMode10kFile - 1 time(s), in 190 ms..
testTenPctFloatIndex - 1 time(s), in 802 ms..
testUpdatesIntIndex - 1 time(s), in 691 ms..
testTenPctDecimIndex - 1 time(s), in 1061 ms..
testHundredCodeIndex - 1 time(s), in 1032 ms..
testMode10kRelation - 1 time(s), in 140 ms..
testTenPctNameIndex - 1 time(s), in 1372 ms..
testUpdatesCodeIndex - 1 time(s), in 911 ms..
testMode100kRelation - 1 time(s), in 331 ms..
testTenPctCodeIndex - 1 time(s), in 1001 ms..
testUpdatesDoubleIndex - 1 time(s), in 821 ms..
testMode1kScreen - 1 time(s), in 110 ms..
testMode10kScreen - 1 time(s), in 171 ms..
testMode100kScreen - 1 time(s), in 681 ms..
testJoin3Clustered - 1 time(s), in 140 ms..
testSelect100NonClustered - 1 time(s), in 120 ms..
testTableScan - 1 time(s), in 90 ms..
testFunctionAggregate - 1 time(s), in 801 ms..
testScalarAggregate - 1 time(s), in 140 ms..
testSelect100Clustered - 1 time(s), in 161 ms..
testJoin3NonClustered - 1 time(s), in 110 ms..
testSelect10TenPctNonClustered - 1 time(s), in 110 ms..
testSimpleReport - 1 time(s), in 9043 ms..
testInfoRetrieval - 1 time(s), in 100 ms..
testCreateView - 1 time(s), in 341 ms..
testSubtotalReport - 1 time(s), in 210 ms..
testTotalReport - 1 time(s), in 180 ms..
testDropView - 1 time(s), in 281 ms..
testJoin2Clustered - 1 time(s), in 90 ms..
testJoin2 - 1 time(s), in 510 ms..
testVariableSelectivity - 1 time(s), in 802 ms..
testJoin4Clustered - 1 time(s), in 120 ms..
testProjection100 - 1 time(s), in 1342 ms..
testJoin4NonClustered - 1 time(s), in 110 ms..
testProjectionTenPct - 1 time(s), in 1252 ms..
testSelect1NonClustered - 1 time(s), in 100 ms..
testJoin2NonClustered - 1 time(s), in 110 ms..
testIntegrity - 1 time(s), in 230 ms..
testUpdatesDropIndices - 1 time(s), in 511 ms..
testBulkSave - 1 time(s), in 160 ms..
testBulkModify - 1 time(s), in 2133 ms..
testAppendMiddle - 1 time(s), in 110 ms..
testUpdateMiddle - 1 time(s), in 111 ms..
testDeleteMiddle - 1 time(s), in 120 ms..
testAppendEnd - 1 time(s), in 100 ms..
testUpdateEnd - 1 time(s), in 140 ms..
testDeleteEnd - 1 time(s), in 100 ms..
testUpdatesCodeIndex - 1 time(s), in 2654 ms..
testAppendMiddle - 1 time(s), in 110 ms..
testUpdateMiddleCode - 1 time(s), in 100 ms..
testDeleteMiddle - 1 time(s), in 101 ms..
testUpdatesIntIndex - 1 time(s), in 681 ms..
testAppendMiddle - 1 time(s), in 100 ms..
testUpdateMiddleInt - 1 time(s), in 110 ms..
testDeleteMiddle - 1 time(s), in 150 ms..
testBulkAppend - 1 time(s), in 6199 ms..
testBulkDelete - 1 time(s), in 2233 ms..
マルチユーザーテスト
次は、マルチユーザーモードでベンチマークを取ってみましょう。benchmarkSuite.properties で指定したuserCountが40なので、40本のスレッドを生成しての同時アクセスとなります。以下のコマンドをコマンドプロンプトで実行します。
>java -cp %CLASSPATH%;lib\junit.jar;firebirdsql_as3ap.jar org.firebirdsql.benchmark.MultiUserSuite
Time: 5,983.013
OK (1 tests)
Test execution statistics:
testMultiUser - 1 time(s), in 5982893 ms..
testIrSelect - 1 time(s), in 1226894 ms..
testIrSelect - 1 time(s), in 1273000 ms..
testIrSelect - 1 time(s), in 1273140 ms..
testIrSelect - 1 time(s), in 1272840 ms..
testIrSelect - 1 time(s), in 1272930 ms..
testIrSelect - 1 time(s), in 1272940 ms..
testIrSelect - 1 time(s), in 1273080 ms..
testIrSelect - 1 time(s), in 1272850 ms..
testIrSelect - 1 time(s), in 1272910 ms..
testIrSelect - 1 time(s), in 1273030 ms..
testIrSelect - 1 time(s), in 1273020 ms..
testIrSelect - 1 time(s), in 1273110 ms..
testIrSelect - 1 time(s), in 1272990 ms..
testIrSelect - 1 time(s), in 1272810 ms..
testIrSelect - 1 time(s), in 1273100 ms..
testIrSelect - 1 time(s), in 1272960 ms..
testIrSelect - 1 time(s), in 1272870 ms..
testIrSelect - 1 time(s), in 1273070 ms..
testIrSelect - 1 time(s), in 1272930 ms..
testIrSelect - 1 time(s), in 1273040 ms..
testIrSelect - 1 time(s), in 1273010 ms..
testIrSelect - 1 time(s), in 0 ms., 1 errors.
java.sql.SQLException: Could not obtain connection during blocking timeout (1 ms
)
testIrSelect - 1 time(s), in 1272990 ms..
testIrSelect - 1 time(s), in 1273151 ms..
testIrSelect - 1 time(s), in 1272790 ms..
testIrSelect - 1 time(s), in 1272940 ms..
testIrSelect - 1 time(s), in 1272810 ms..
testIrSelect - 1 time(s), in 1272900 ms..
testIrSelect - 1 time(s), in 1273080 ms..
testIrSelect - 1 time(s), in 1273090 ms..
testIrSelect - 1 time(s), in 1272940 ms..
testIrSelect - 1 time(s), in 1272810 ms..
testIrSelect - 1 time(s), in 1273030 ms..
testIrSelect - 1 time(s), in 1272830 ms..
testIrSelect - 1 time(s), in 1272790 ms..
testIrSelect - 1 time(s), in 1273070 ms..
testIrSelect - 1 time(s), in 1273030 ms..
testIrSelect - 1 time(s), in 1273080 ms..
testIrSelect - 1 time(s), in 1273070 ms..
testIrSelect - 1 time(s), in 1272920 ms..
testIrSelect - 1 time(s), in 326509 ms..
testCrossSection - 1 time(s), in 46037 ms..
testCheck - 1 time(s), in 100 ms..
testRestoreUpdates - 1 time(s), in 944548 ms..
testCheck - 1 time(s), in 120 ms..
testOltpUpdate - 1 time(s), in 1202980 ms..
testOltpUpdate - 1 time(s), in 3764463 ms..
testOltpUpdate - 1 time(s), in 3764503 ms..
testOltpUpdate - 1 time(s), in 3760538 ms..
testOltpUpdate - 1 time(s), in 3764113 ms..
testOltpUpdate - 1 time(s), in 3763953 ms..
testOltpUpdate - 1 time(s), in 3764433 ms..
testOltpUpdate - 1 time(s), in 3764263 ms..
testOltpUpdate - 1 time(s), in 3764353 ms..
testOltpUpdate - 1 time(s), in 3760518 ms..
testOltpUpdate - 1 time(s), in 3764453 ms..
testOltpUpdate - 1 time(s), in 3764193 ms..
testOltpUpdate - 1 time(s), in 3764043 ms..
testOltpUpdate - 1 time(s), in 3764514 ms..
testOltpUpdate - 1 time(s), in 3764213 ms..
testOltpUpdate - 1 time(s), in 3764273 ms..
testOltpUpdate - 1 time(s), in 3764413 ms..
testOltpUpdate - 1 time(s), in 3764463 ms..
testOltpUpdate - 1 time(s), in 3764363 ms..
testOltpUpdate - 1 time(s), in 3764133 ms..
testOltpUpdate - 1 time(s), in 3764313 ms..
testOltpUpdate - 1 time(s), in 3764153 ms..
testOltpUpdate - 1 time(s), in 3764283 ms..
testOltpUpdate - 1 time(s), in 3764073 ms..
testOltpUpdate - 1 time(s), in 3764483 ms..
testOltpUpdate - 1 time(s), in 3764233 ms..
testOltpUpdate - 1 time(s), in 3764383 ms..
testOltpUpdate - 1 time(s), in 3764323 ms..
testOltpUpdate - 1 time(s), in 3764223 ms..
testOltpUpdate - 1 time(s), in 3764393 ms..
testOltpUpdate - 1 time(s), in 3764273 ms..
testOltpUpdate - 1 time(s), in 3764053 ms..
testOltpUpdate - 1 time(s), in 3764003 ms..
testOltpUpdate - 1 time(s), in 3764253 ms..
testOltpUpdate - 1 time(s), in 3764493 ms..
testOltpUpdate - 1 time(s), in 3764413 ms..
testOltpUpdate - 1 time(s), in 3764283 ms..
testOltpUpdate - 1 time(s), in 3764363 ms..
testOltpUpdate - 1 time(s), in 3764453 ms..
testOltpUpdate - 1 time(s), in 3763953 ms..
testIrSelect - 1 time(s), in 301072 ms..
testCrossSection - 1 time(s), in 2559261 ms..
testCheck - 1 time(s), in 110 ms..
約100分かかりました。testIrSelectのテストで1ms以内でコネクトできなかったというエラーが一つ出ています。
結論
これで、Firebirdのベンチマークテストが run anywhere で行えるようになったので、ぜひ皆さんも試してみて下さい。また、Firebirdの新しいバージョンが公開されると、まずは as3ap ベンチで SingleUserSuite を実行してちゃんと動くのかどうかを試して見ていたりします。試してみて、エラーがあったりしたら firebird-devel リストへぜひ投げて下さい。