ABSTRACT
The compilation of a project from source to machine code can take up to hours of computation time which in large part depends on how many lines of code are compiled. In the programming language C++, source code is written in separate header and source files. The code in a header file is compiled in each source file it is included in. In order to minimize the compilation time of the project, code should therefore be included only in source files where it is actually used. We present an optimization model that minimizes the number of lines of code that are included and hence compiled but not used. The restrictions of the model are the dependencies in the code. For example, when a function is called in a source file, the header file where this function is defined in must be included in the source file. The variables of the model are which file includes which other files. We propose the solution method to replace indirect includes by more direct ones. We provide computational results on read-world C++ projects and show that the compilation times can be reduced by up to 9%.
- Datrix. 2000. DATRIX Abstract Semaantic Graph Reference Manual. Technical Report. Bell-Canada. http://citeseer.ist.psu.edu/bell00datrix.htmlGoogle Scholar
- Bruce Dawson. 2020. Big Project Build Times–Chromium. https://randomascii.wordpress.com/2020/03/30/big-project-build-times-chromium/. Accessed: 2022-03-02.Google Scholar
- Martin Fowler. 1999. Refactoring: Improving the Design of Existing Code. Addison-Wesley Longman Publishing Co., Inc., USA.Google ScholarDigital Library
- Elisabeth Gassner. 2010. The Steiner Forest Problem revisited. Journal of Discrete Algorithms 8, 2 (2010), 154–163. https://doi.org/10.1016/j.jda.2009.05.002 Selected papers from the 3rd Algorithms and Complexity in Durham Workshop ACiD 2007.Google ScholarDigital Library
- Kaur, Amandeep and Kaur, Manpreet. 2016. Analysis of Code Refactoring Impact on Software Quality. MATEC Web of Conferences 57 (2016), 02012. https://doi.org/10.1051/matecconf/20165702012Google Scholar
- Gernot Klinger. 2014. Why you should care about include dependencies in C++ and how to keep them at a minimum. https://gernotklingler.com/blog/care-include-dependencies-cpp-keep-minimum/. Accessed: 2021-06-30.Google Scholar
- John Lakos. 1996. Large-Scale C++ Software Design. Addison Wesley Longman Publishing Co., Inc., USA.Google Scholar
- Chris Lattner and Vikram Adve. 2004. LLVM: A Compilation Framework for Lifelong Program Analysis and Transformation. San Jose, CA, USA, 75–88.Google Scholar
- PYPL. 2021. PopularitY of Programming Language. https://pypl.github.io/PYPL.html. Accessed: 2021-11-17.Google Scholar
- Julian Reisch, Peter Großmann, and Natalia Kliewer. 2020. Stable Resolving - A Randomized Local Search Heuristic for MaxSAT. In KI 2020: Advances in Artificial Intelligence, Ute Schmid, Franziska Klügl, and Diedrich Wolter (Eds.). Springer International Publishing, Cham, 163–175.Google Scholar
- Julian Reisch, Peter Großmann, and Reyk Weiß. 2022. Chronopath. (2 2022). https://doi.org/10.6084/m9.figshare.19103399.v1Google Scholar
- Simone Romano, Giuseppe Scanniello, Carlo Sartiani, and Michele Risi. 2016. A Graph-Based Approach to Detect Unreachable Methods in Java Software. In Proceedings of the 31st Annual ACM Symposium on Applied Computing (Pisa, Italy) (SAC ’16). Association for Computing Machinery, New York, NY, USA, 1538–1541. https://doi.org/10.1145/2851613.2851968Google ScholarDigital Library
- Simone Romano, Christopher Vendome, Giuseppe Scanniello, and Denys Poshyvanyk. 2020. A Multi-Study Investigation into Dead Code. IEEE Transactions on Software Engineering 46, 1 (2020), 71–99. https://doi.org/10.1109/TSE.2018.2842781Google ScholarCross Ref
- Diomidis Spinellis. 2009. Optimizing Header File Include Directives. Journal of Software Maintenance and Evolution: Research and Practice 21, 4 (July/August 2009), 233–251. https://doi.org/10.1002/smr.369Google ScholarCross Ref
- Yijun Yu, Homy Dayani-Fard, and John Mylopoulos. 2003. Removing False Code Dependencies to Speedup Software Build Processes. In Proceedings of the 2003 Conference of the Centre for Advanced Studies on Collaborative Research (Toronto, Ontario, Canada) (CASCON ’03). 343–352.Google ScholarDigital Library
Index Terms
- Automatic Refactoring and Compile Time Optimization of Cpp Projects by Directly Including Header Files
Recommendations
Compile-time meta-programming in a dynamically typed OO language
DLS '05: Proceedings of the 2005 symposium on Dynamic languagesCompile-time meta-programming allows programs to be constructed by the user at compile-time. Although LISP derived languages have long had such facilities, few modern languages are capable of compile-time meta-programming, and of those that do many of ...
An integrated implementation framework for compile-time metaprogramming
Compile-time metaprograms are programs executed during the compilation of a source file, usually targeting to update its source code. Even though metaprograms are essentially programs, they are typically treated as exceptional cases without sharing ...
Comments