Published a set of patches accelerating Linux kernel assembly by 50-80%

Ingo Molnar ( Ingo Molnar ), a well-known developer of Linux kernel and the author of the CFS task scheduler (Completely Fair Scheduler), suggested for discussion in the Linux kernel developer maternal list series of patches affecting more than half of all files in the source The kernel texts and ensure an increase in the speed of the full rebeling of the nucleus by 50-80% depending on the settings. The implemented optimization is notable in that it is associated with the addition of the largest change in the development of the change kernel – for inclusion of the time, 2297 patches changering more than 25 thousand files (10 thousand header files in the “Include /” and Arch / * / Include / “catalogs / “And 15 thousand files with source texts).

Performance growth is achieved due to the change in the processing method of header files. It is noted that in the thirty years of the core development, the state of the header files has taken a depressing view due to the presence of a large number of cross-line dependencies between files.
Work on the restructuring of header files took more than a year and demanded a significant processing of hierarchy and dependencies. During the restructuring, work was performed on the separation of definitions of types and APIs for different nucleus subsystems.

Among the changes made: separation of high-level header files from each other, eliminating binding header files inline functions, highlight header files for types and APIs, providing a separate assembly of header files (about 80 files have interfered with the indirect dependencies, exposed through other headerence Files), automatic adding dependences to files “.h” and “.c”, step-by-step optimization of header files, using the “config_kallsyms_fast = y” mode, selective consolidation of C-files in assembly blocks to reduce the number of object files.

As a result, the work done allowed 1-2 order to reduce the size of the header files processed at the postprocessing stage. For example, before optimizing the use of the header file “Linux / GFP.H” led to the addition of 13543 rows of code and connect 303 dependent header files, and after optimizing the size decreased to 181 lines and 26 dependent files. Or another example: in the prepression of the “kernel / pid.c” file, 94 thousand rows of code are connected without a patch, most of which is not used in PID.C. The separation of header files made it possible to reduce the volume of the processed code three times, reducing the number of rows processed to 36 thousand.

With a complete rebuilding of the kernel with the command “make -j96 vmlinux” on test systems, the use of patches showed a reduction in the assembly time of the V5.16-RC7 branch from 231.34 to 129.97 seconds (from 27.7 to 15.5 assemblies per hour), and also increased the efficiency of the use of cores CPU during the assembly. When an incremental assembly, the optimization effect is even more noticeable – the re-rebeling time of the kernel after mapping changes to the header files decreased at times (from 112% to 173%, depending on the changeable header file). Optimizations are still available only for Arm64, MIPS, SPARC and X86 architectures (32- and 64-bit).

/Media reports.