Does source code compatibility really increase the performance of a C or C ++ program?

Combining code is to copy the entire source code into a single file.

For example, this is done by SQLite to reduce compilation time and increase the performance of the resulting executable. Here it displays a single file of 184K lines of code.

My question is not about compilation time (already answered in this question ), but about the efficiency of the executable file.

SQLite developers say:

In addition to simplifying the integration of SQLite into other projects, consolidation also speeds up its work. Many compilers can perform additional code optimizations when they are contained in a single translation unit, for example, in a union. We measured a performance improvement of 5 to 10% when we use the join to compile SQLite, rather than individual source files. The disadvantage of this is that additional optimizations often take the form of a function that seeks to increase the size of the resulting binary image.

From what I understood, this is due to interprocedural optimization (IPO) , optimization made by the compiler.

GCC developers also talk about this (thanks @nwp for the link):

, . , .

.

- , SQLite, , IPO , IPO gcc?

, , # .cpp( .c) ?

+4
1

" ", .

.

, , , : . " A" " B", " A", , API- .

, , () , , , , . ( Makefile .) " ", , ... , .

, ( ...) : . , ... . .

, (, .DLL .so), , , .

, , - . ( .) , .

+2

Source: https://habr.com/ru/post/1650930/


All Articles