Why does SQLite provide amalgamations of their code?

1.1k views Asked by At

Every time I download SQLite, I come across the fact that they provide several different versions of their source code, which is something I've actually never seen any other project do. And more so they provide Amalgamations of Source, that kind of merge all their files into just 3 files. What's the reason for this? Is it just compilation speed? Or are there some really good reasons for it? Do other projects use Amalgamations of source code?

3

There are 3 answers

1
Zuu On BEST ANSWER

As stated directly on their page about amalgamation

In addition to making SQLite easier to incorporate into other projects, the amalgamation also makes it run faster. Many compilers are able to do additional optimizations on code when it is contained with in a single translation unit such as it is in the amalgamation. We have measured performance improvements of between 5 and 10% when we use the amalgamation to compile SQLite rather than individual source files. The downside of this is that the additional optimizations often take the form of function inlining which tends to make the size of the resulting binary image larger.

I myself see's the incorporation into other projects the greatest benefit. It simply makes it much much easier to compile. No build script mess and whatever else follows from having a large collection of source files.

3
Gregor Brandt On

It's done to make incorporation into existing projects simpler. Add one .h and one .c to your project, and you have the full SQLite engine.

I appreciate it. It's one less thing I have to worry about.

1
Harvis Wang On

When I trid devide amalgamation file to individual files under windows with dev c++ compiler, I got a lots of question. Because I want make sqlite working in a RTOS which named DJYOS, it's easier to change code from individual files than from amalgamation one.