Small. Fast. Reliable.
Choose any three.

Size Of The SQLite Library

The code space used by the SQLite library depends on the target platform, the compiler, and optimization settings. These variables also affect performance.

The chart below shows the relative size and performance for SQLite as of 2017-10-08 for various compilers and optimization settings as tested on Ubuntu 16.04.3 on x86_64. General observations:

  1. The Clang/LLVM compiler is not competitive with GCC. Clang-generated binaries are consistently larger and slower than GCC-generated binaries.

  2. Profile guided optimization (PGO) is not helpful with SQLite. PGO results in binaries that are about 1% larger and about 0.33% slower.

  3. GCC-7 generates binaries that are smaller and faster than GCC-5, though the difference is not that great.

  4. Compiling with GCC and -Os results in a binary that is slightly less than 500KB in size. (Update 2018-07-07: Due to the addition of new features such as UPSERT and window functions, the library footprint is now slightly larger than 500KB.)

  5. The only significant design decision that developers need to make is whether to use -Os (optimize for size) or -O6 (optimize for speed). The -O6 setting makes binaries that run about 2% or 3% faster, but which are also 66% larger. The performance here is measured by counting CPU cycles using cachegrind. I-cache misses are not considered in the analysis. If I-cache misses are considered, builds with -O6 might not be any faster than builds with -Os.

  6. Taking into consideration all of the above, the SQLite developers recommend compiling SQLite using GCC-7 with the -Os optimization setting.


Details

This page last modified on 2022-01-08 05:02:57 UTC