Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does SQLite provide amalgamations of their code?

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?

like image 568
Robert Gould Avatar asked Feb 18 '09 01:02

Robert Gould


2 Answers

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.

like image 193
Zuu Avatar answered Nov 29 '22 18:11

Zuu


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.

like image 40
Gregor Brandt Avatar answered Nov 29 '22 20:11

Gregor Brandt