From: Tomek Mrugalski Date: Mon, 16 Jul 2012 10:58:34 +0000 (+0200) Subject: [2041] SQLite benchmark coding complete. X-Git-Tag: trac2351_base~117^2~25 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7f37eed04092bb2f7babb50eadb10e28d3d776eb;p=thirdparty%2Fkea.git [2041] SQLite benchmark coding complete. --- diff --git a/tests/tools/dhcp-ubench/Makefile b/tests/tools/dhcp-ubench/Makefile index 0ef6a32c01..5bc2f719fe 100644 --- a/tests/tools/dhcp-ubench/Makefile +++ b/tests/tools/dhcp-ubench/Makefile @@ -24,4 +24,4 @@ sqlite_ubench: sqlite_ubench.o benchmark.o $(CXX) $< benchmark.o -o sqlite_ubench $(CFLAGS) $(SQLITE_CFLAGS) $(SQLITE_LDFLAGS) clean: - rm -f mysql_ubench *.o + rm -f mysql_ubench sqlite_ubench *.o diff --git a/tests/tools/dhcp-ubench/README b/tests/tools/dhcp-ubench/README index 463ec3e6d1..6e48dc745c 100644 --- a/tests/tools/dhcp-ubench/README +++ b/tests/tools/dhcp-ubench/README @@ -64,7 +64,7 @@ WARNING: It will drop existing Kea database. Do not run this on your production server. Assuming your MySQL user is kea, you can initialize your test database by: -mysql -u kea -p < mysql-init.sql +mysql -u kea -p < mysql.schema After that step, you are ready to run the test: @@ -72,7 +72,7 @@ After that step, you are ready to run the test: or -./mysql_ubench > results.txt +./mysql_ubench > results-mysql.txt Redirecting output to a file is important, because for each operation there is a single character printed to show progress. If you have a slow @@ -100,3 +100,45 @@ can tweak it by using the following command in mysql: or > alter table lease4 engine=InnoDB; + + SQLite backend +---------------- +SQLite backend requires both sqlite3 development and run-time package. Their +names may vary from system to system, but on Ubuntu 12.04 they are called +sqlite3 libsqlite3-dev. To install them, use the following command: + +sudo apt-get install sqlite3 libsqlite3-dev + +To run SQLite3 tests, first create the database: + +cat sqlite.schema | sqlite3 sqlite.db + +A new database called sqlite.db will be created. That is the default name used +by sqlite_ubench test. If you prefer other name, make sure you update +sqlite_ubench.cc accordingly. Once the database is created, you can run +tests: + +./sqlite_ubench > results-sqlite.txt + +Make sure to tweak number of iterations in sqlite_ubench.cc. See num variable +in main() function near the end of sqlite_ubench.cc file. + +To improve performance, asynchronous mode is used (PRAGMA synchronous = OFF). +If you do not like it, modify SQLite_uBenchmark::connect() by commenting it out +and suffer the pain of having around 10 inserts per seconds. + + Performance optimizations +--------------------------- + +The following section is a collection of loose notes, ideas and comments that +could be investigated to possibly improve (or thrash) performance. Please +consider them as developer's scratchpad only. However, if you are experienced +programmer or a DB admin, you are welcome to try some of them. ISC engineers +are more than welcome to discuss pros and cons of various approaches on +bind10-dev@lists.isc.org list. + +- SQLite: Excellent article that discusses performance optimizations: + - http://stackoverflow.com/questions/1711631/how-do-i-improve-the-performance-of-sqlite + - http://blog.quibb.org/2010/08/fast-bulk-inserts-into-sqlite/ + - use prepared statements + - use journal mode in memory (or disable it completely) diff --git a/tests/tools/dhcp-ubench/mysql-schema.sql b/tests/tools/dhcp-ubench/mysql.schema similarity index 100% rename from tests/tools/dhcp-ubench/mysql-schema.sql rename to tests/tools/dhcp-ubench/mysql.schema diff --git a/tests/tools/dhcp-ubench/sqlite_ubench.cc b/tests/tools/dhcp-ubench/sqlite_ubench.cc index fef196164b..19a9e8a888 100644 --- a/tests/tools/dhcp-ubench/sqlite_ubench.cc +++ b/tests/tools/dhcp-ubench/sqlite_ubench.cc @@ -40,7 +40,14 @@ void SQLite_uBenchmark::connect() { failure("Failed to open DB file"); } - sqlite3_exec(DB_, "DELETE FROM lease4", 0, 0, 0); + sqlite3_exec(DB_, "DELETE FROM lease4", NULL, NULL, NULL); + + sqlite3_exec(DB_, "PRAGMA synchronous = OFF", NULL, NULL, NULL); + + // see http://www.sqlite.org/pragma.html#pragma_journal_mode + // for detailed explanation. Available modes: DELETE, TRUNCATE, + // PERSIST, MEMORY, WAL, OFF + sqlite3_exec(DB_, "PRAGMA journal_mode = OFF", NULL, NULL, NULL); } void SQLite_uBenchmark::disconnect() { @@ -235,7 +242,7 @@ void SQLite_uBenchmark::printInfo() { int main(int argc, const char * argv[]) { const char * filename = "sqlite.db"; - uint32_t num = 10; + uint32_t num = 10000; SQLite_uBenchmark bench(filename, num);