Benchmarks

This table shows the performance of Persist vs a fast SQL database vs in-memory data structures on Linux.  The benchmark utilises an indexed table of [name, address, telephone], and performs 1) creation of rows (one query per row), 2) sequential retrieval (one query per row), 3) random retrieval (one query per row), and 4) delete (one query per row).  None of these functions particularly dominated the results.

Rows a. MySQL (seconds) b. Persist+STL (seconds) c. STL (seconds) a/b
100 0.044 0.005 0.005 8.8
1,000 0.424 0.017 0.017 24.9
10,000 4.465 0.169 0.156 26.4
100,000 48.823 1.798 1.82 27.2
1,000,000 575.214 20.392 20.098 28.2

The results show Persist to be around 25 times faster than SQL, and interestingly seems to do even better at larger table sizes.  It also shows Persist to be as fast as normal memory.

One would expect SQL to perform a bit better when multiple rows per query are retrieved, or when the query becomes complex.  While this is a very trivial benchmark, real-life use of databases is dominated by simple single-row queries.  Persist outperforms SQL for several reasons.  Firstly, the "query" is optimized by the C++ compiler, which compiles and optimizes the query specifically for the data-type.  There is no parsing of a text query.  Secondly the IO is reduced.  The operating system maps the data directly into the address space of the application, there is no streaming of data from one location to another.

Although significantly slower, this does not mean that databases will be superseded by PersistPersist failed to complete 10,000,000 rows, by no means a high number, which means that databases, for now, have the edge on scalability.  This limitation was due to the 32-bit address space, which will cease to be an issue when 64-bit addressing is common.  However, the MySQL table size in Linux is also limited by the operating system to 2GB.  Databases offer a raft of facilities not provided by Persist, not least of which is data protection.

The benchmark is included with the download.

Platform

Hardware: Intel Pentium 4 processor, 2.4GHz.  512MB RAM.
Operating System: Linux 2.4.18
Software: gcc-3.2, MySQL-3.23.56, persist-0.9