skip to main content
10.1145/3543712.3543724acmotherconferencesArticle/Chapter ViewAbstractPublication PagesicctaConference Proceedingsconference-collections
research-article

Automatic Refactoring and Compile Time Optimization of Cpp Projects by Directly Including Header Files

Published:20 September 2022Publication History

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%.

References

  1. Datrix. 2000. DATRIX Abstract Semaantic Graph Reference Manual. Technical Report. Bell-Canada. http://citeseer.ist.psu.edu/bell00datrix.htmlGoogle ScholarGoogle Scholar
  2. 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 ScholarGoogle Scholar
  3. Martin Fowler. 1999. Refactoring: Improving the Design of Existing Code. Addison-Wesley Longman Publishing Co., Inc., USA.Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  5. 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 ScholarGoogle Scholar
  6. 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 ScholarGoogle Scholar
  7. John Lakos. 1996. Large-Scale C++ Software Design. Addison Wesley Longman Publishing Co., Inc., USA.Google ScholarGoogle Scholar
  8. Chris Lattner and Vikram Adve. 2004. LLVM: A Compilation Framework for Lifelong Program Analysis and Transformation. San Jose, CA, USA, 75–88.Google ScholarGoogle Scholar
  9. PYPL. 2021. PopularitY of Programming Language. https://pypl.github.io/PYPL.html. Accessed: 2021-11-17.Google ScholarGoogle Scholar
  10. 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 ScholarGoogle Scholar
  11. Julian Reisch, Peter Großmann, and Reyk Weiß. 2022. Chronopath. (2 2022). https://doi.org/10.6084/m9.figshare.19103399.v1Google ScholarGoogle Scholar
  12. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  13. 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 ScholarGoogle ScholarCross RefCross Ref
  14. 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 ScholarGoogle ScholarCross RefCross Ref
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Automatic Refactoring and Compile Time Optimization of Cpp Projects by Directly Including Header Files

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in
      • Published in

        cover image ACM Other conferences
        ICCTA '22: Proceedings of the 2022 8th International Conference on Computer Technology Applications
        May 2022
        286 pages
        ISBN:9781450396226
        DOI:10.1145/3543712

        Copyright © 2022 ACM

        Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 20 September 2022

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • research-article
        • Research
        • Refereed limited
      • Article Metrics

        • Downloads (Last 12 months)10
        • Downloads (Last 6 weeks)0

        Other Metrics

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader

      HTML Format

      View this article in HTML Format .

      View HTML Format