2012-03-08

SQLite Performance Test on ARM

Platform: 

ARM9 @400MHz, Linux 2.6.27, Nand Flash, Poco C++ Library for test program

Test Setup:

Test Data Structure:

struct Record {
  UInt64 f0,
  UInt32 f1,
  UInt32 f2,

  UInt32 f3,
  UInt32 f4,
  UInt32 f5,
}

All the test guarantee all the fields have value big enough to use 8 bytes or 4 bytes in the SQLite database.


Database:

Tests are done with 6 different database:

  1. 10K records with index
  2. 10K records without index
  3. 40K records with index
  4. 40K records without index
  5. 100K records with index
  6. 100K records without index
Test Items:

The test focus on testing the time performance on creating these database, random search, random insert, random update, random delete, and bulk insert, as well as the database size.

Test Result:

# ./App 
--------------
DB file: 10k-indexd.db, size: 10000 records, indexed: yes
  Time to create db (in one transaction): 18117681 us, each 1811 us
  DB file size: 784384 bytes
  Random insert 10 times in 254177 us, each 25417 us
  Bulk insert 100 random records in 1031018 us, each 10310 us
  Bulk insert 1000 random records in 3079258 us, each 3079 us
  Random search 10 times in 6534 us, each 653 us
  Random search non exist 10 times in 5169 us, each 516 us
  Random update 10 times in 149859 us, each 14985 us
  Random delete 10 times in 354457 us, each 35445 us
  DB file size: 839680 bytes
  Done!
--------------
DB file: 10k.db, size: 10000 records, indexed: no
  Time to create db (in one transaction): 17041652 us, each 1704 us
  DB file size: 600064 bytes
  Random insert 10 times in 260593 us, each 26059 us
  Bulk insert 100 random records in 614959 us, each 6149 us
  Bulk insert 1000 random records in 1794085 us, each 1794 us
  Random search 10 times in 6615 us, each 661 us
  Random search non exist 10 times in 4967 us, each 496 us
  Random update 10 times in 214609 us, each 21460 us
  Random delete 10 times in 237757 us, each 23775 us
  DB file size: 649216 bytes
  Done!
--------------
DB file: 40k-indexd.db, size: 40000 records, indexed: yes
  Time to create db (in one transaction): 75025477 us, each 1875 us
  DB file size: 3188736 bytes
  Random insert 10 times in 277867 us, each 27786 us
  Bulk insert 100 random records in 1195125 us, each 11951 us
  Bulk insert 1000 random records in 7720179 us, each 7720 us
  Random search 10 times in 7511 us, each 751 us
  Random search non exist 10 times in 5408 us, each 540 us
  Random update 10 times in 301528 us, each 30152 us
  Random delete 10 times in 495317 us, each 49531 us
  DB file size: 3231744 bytes
  Done!
--------------
DB file: 40k.db, size: 40000 records, indexed: no
  Time to create db (in one transaction): 67904547 us, each 1697 us
  DB file size: 2443264 bytes
  Random insert 10 times in 238309 us, each 23830 us
  Bulk insert 100 random records in 645656 us, each 6456 us
  Bulk insert 1000 random records in 4397617 us, each 4397 us
  Random search 10 times in 6991 us, each 699 us
  Random search non exist 10 times in 5942 us, each 594 us
  Random update 10 times in 264723 us, each 26472 us
  Random delete 10 times in 322832 us, each 32283 us
  DB file size: 2486272 bytes
  Done!
--------------
DB file: 100k-indexd.db, size: 100000 records, indexed: yes
  Time to create db (in one transaction): 188842785 us, each 1888 us
  DB file size: 8145920 bytes
  Random insert 10 times in 272809 us, each 27280 us
  Bulk insert 100 random records in 1191890 us, each 11918 us
  Bulk insert 1000 random records in 11077409 us, each 11077 us
  Random search 10 times in 8111 us, each 811 us
  Random search non exist 10 times in 6592 us, each 659 us
  Random update 10 times in 266008 us, each 26600 us
  Random delete 10 times in 444581 us, each 44458 us
  DB file size: 8189952 bytes
  Done!
--------------
DB file: 100k.db, size: 100000 records, indexed: no
  Time to create db (in one transaction): 170344875 us, each 1703 us
  DB file size: 6214656 bytes
  Random insert 10 times in 173419 us, each 17341 us
  Bulk insert 100 random records in 643810 us, each 6438 us
  Bulk insert 1000 random records in 5662638 us, each 5662 us
  Random search 10 times in 14928 us, each 1492 us
  Random search non exist 10 times in 5742 us, each 574 us
  Random update 10 times in 337846 us, each 33784 us
  Random delete 10 times in 291406 us, each 29140 us
  DB file size: 6258688 bytes
  Done!


Result on x86:

As a reference, this is the result on the Ubuntu in VMware virtual machine. (During the test, some other programs also running).


one@ubuntu:~/tmp/app/bin/Linux/i686$ ./App
--------------
DB file: 10k-indexd.db, size: 10000 records, indexed: yes
  Time to create db (in one transaction): 442684 us, each 44 us
  DB file size: 784384 bytes
  Random insert 10 times in 45290 us, each 4529 us
  Bulk insert 100 random records in 23660 us, each 236 us
  Bulk insert 1000 random records in 35567 us, each 35 us
  Random search 10 times in 235 us, each 23 us
  Random search non exist 10 times in 183 us, each 18 us
  Random update 10 times in 37714 us, each 3771 us
  Random delete 10 times in 32167 us, each 3216 us
  DB file size: 847872 bytes
  Done!
--------------
DB file: 10k.db, size: 10000 records, indexed: no
  Time to create db (in one transaction): 414712 us, each 41 us
  DB file size: 600064 bytes
  Random insert 10 times in 41590 us, each 4159 us
  Bulk insert 100 random records in 27343 us, each 273 us
  Bulk insert 1000 random records in 25190 us, each 25 us
  Random search 10 times in 235 us, each 23 us
  Random search non exist 10 times in 201 us, each 20 us
  Random update 10 times in 33079 us, each 3307 us
  Random delete 10 times in 35359 us, each 3535 us
  DB file size: 644096 bytes
  Done!
--------------
DB file: 40k-indexd.db, size: 40000 records, indexed: yes
  Time to create db (in one transaction): 1782219 us, each 44 us
  DB file size: 3188736 bytes
  Random insert 10 times in 26208 us, each 2620 us
  Bulk insert 100 random records in 30767 us, each 307 us
  Bulk insert 1000 random records in 68072 us, each 68 us
  Random search 10 times in 312 us, each 31 us
  Random search non exist 10 times in 267 us, each 26 us
  Random update 10 times in 26809 us, each 2680 us
  Random delete 10 times in 33644 us, each 3364 us
  DB file size: 3231744 bytes
  Done!
--------------
DB file: 40k.db, size: 40000 records, indexed: no
  Time to create db (in one transaction): 1606878 us, each 40 us
  DB file size: 2443264 bytes
  Random insert 10 times in 41207 us, each 4120 us
  Bulk insert 100 random records in 27617 us, each 276 us
  Bulk insert 1000 random records in 200214 us, each 200 us
  Random search 10 times in 308 us, each 30 us
  Random search non exist 10 times in 344 us, each 34 us
  Random update 10 times in 27387 us, each 2738 us
  Random delete 10 times in 40206 us, each 4020 us
  DB file size: 2486272 bytes
  Done!
--------------
DB file: 100k-indexd.db, size: 100000 records, indexed: yes
  Time to create db (in one transaction): 4379620 us, each 43 us
  DB file size: 8145920 bytes
  Random insert 10 times in 29942 us, each 2994 us
  Bulk insert 100 random records in 28524 us, each 285 us
  Bulk insert 1000 random records in 446084 us, each 446 us
  Random search 10 times in 336 us, each 33 us
  Random search non exist 10 times in 284 us, each 28 us
  Random update 10 times in 23732 us, each 2373 us
  Random delete 10 times in 29532 us, each 2953 us
  DB file size: 8189952 bytes
  Done!
--------------
DB file: 100k.db, size: 100000 records, indexed: no
  Time to create db (in one transaction): 3994606 us, each 39 us
  DB file size: 6214656 bytes
  Random insert 10 times in 34722 us, each 3472 us
  Bulk insert 100 random records in 170171 us, each 1701 us
  Bulk insert 1000 random records in 234747 us, each 234 us
  Random search 10 times in 331 us, each 33 us
  Random search non exist 10 times in 280 us, each 28 us
  Random update 10 times in 28106 us, each 2810 us
  Random delete 10 times in 23698 us, each 2369 us
  DB file size: 6258688 bytes
  Done!


Performance of C++ STL map:

As another reference, this is the test result with C++ STL map container on ARM. A map with 100000 cardholders is created as the database, and try to insert 10 new records and search them.


Test map performance: 100000 cardholders
  Random insert 10 cards in 339 us, each 33 us
  Random search 10 cards in 75 us, each 7 us





2012-03-06

交叉编译Poco 1.4.2p1

  1. Ubuntu Linux作为开发环境,使用gcc交叉编译为ARM处理器。编译器:arm-angstrom-linux-gnueabi-gcc。
  2. 下载poco 1.4.2p1,并解压,进入解压后的目录。
  3. 创建配置文件:
    1. 有两个配置文件可以使用:build/config/Angstrom和build/config/ARM-Linux。Angstrom没有指定openssl库的头文件和库文件的位置,所以除非它们在编译器已知的位置,否则会编译不通过。ARM-Linux使用STLport作为C++的标准库,而不是gcc自带的C++标准库,而且在配置文件中有指定openssl的位置信息。
    2. 由于我们已经有gcc自带的C++标准库,所以不需要STDport。而且我们希望指定Openssl的位置。所以我们需要创建一个自己的配置文件,可以基于这两个文件的任何一个。这里以ARM-Linux为基础。
    3. 在build/config目录中,复制ARM-Linux为AT91-Linux。修改AT91-Linux文件:
      1. 修改OPENSSL_INCLUDE和OPENSSL_LIB,使他们指向正确的目录。
      2. 修改TOOL为:arm-angstrom-linux-gnueabi。
      3. 修改SYSFLAGS:去掉‘-I$(STLPORT_INCLUDE)'。
      4. 修改SYSLIBS:去掉'-L$(STLPORT_LIB)'。
  4. 配置代码:回到poco顶级目录,运行:./configure --config=AT91-Linux --omit=Data/ODBC,Data/MySQL,PageCompiler,PageCompiler/File2Page
  5. 编译代码:make
  6. 编译的结果在:lib/Linux/ARM中。
  7. stripped库大小为:4.9MB,包括:CppUnit, Crypto, Data, DataSQLite, Foundation, Net, NetSSL, Util, XML, Zip.

Embedded Linux Memory Consumption

ARM Linux 2.6.27.19 on Atmel

After starts up, 'top' shows 17892K memory used.

After starts dropbear, another 192K used.

After starts lighttpd and two php-cgi processes, it takes another 1444K.

The major C++ application (two processes) takes about 6204K.