Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[All] Accelerating CMake generation #1464

Merged
merged 5 commits into from
Aug 28, 2020

Conversation

damienmarchal
Copy link
Contributor

@damienmarchal damienmarchal commented Aug 26, 2020

The cmake part of our build process is very slow and is getting slower and slower the more we add plugins/modules and packages.

I noticed that commands like include or find_package(XXXXX) imply the search, the loading and the execution of the requested package XXXX each time.

This is very problematic as this scale in an horrible (non linear) way.

So I tried a quick and dirty fix based on inclusion gard, 'à la #ifdef MYFILE_H'. I first checked if the file are really loaded multiple times (and this was the case) and implemented a quick test to stop the loading.

The fix accelerates a lot the cmake time on my machine reducing the generation from 1min20 down to 15 sec. So I'm curious to see if such solution is reliable enough to be used (I consider that if this is not the default design of cmake package there must be a rational behind) and what are the possible drawback.


This PR:

  • builds with SUCCESS for all platforms on the CI.
  • does not generate new warnings.
  • does not generate new unit test failures.
  • does not generate new scene test failures.
  • does not break API compatibility.
  • is more than 1 week old (or has fast-merge label).

Reviewers will merge only if all these checks are true.

@damienmarchal damienmarchal added enhancement About a possible enhancement pr: status to review To notify reviewers to review this pull-request labels Aug 26, 2020
@damienmarchal damienmarchal changed the title Accelerate cmake [all] Accelerating CMake generation Aug 26, 2020
To keep cmake generation time low.
damienmarchal added a commit to SofaDefrost/sofa that referenced this pull request Aug 27, 2020
@marques-bruno
Copy link
Member

Can't wait to test this today! Awesome idea!

@marques-bruno
Copy link
Member

With my laptop i7-8850H, cpufreq at around 4.1 GHz:
SofaDefrost:pr-accelerate-cmake With Sofapython3, SofaQtQuick & METIS:
cmake ../sofa 6,85s user 1,35s system 99% cpu 8,238 total

sofa-framework:master same options:
cmake ../sofa 39,17s user 6,96s system 99% cpu 46,426 total

Thank you sir!

@damienmarchal
Copy link
Contributor Author

So it work

@fredroy fredroy merged commit 01f7b78 into sofa-framework:master Aug 28, 2020
@fredroy fredroy added pr: fast merge Minor change that can be merged without waiting for the 7 review days pr: status ready Approved a pull-request, ready to be squashed and removed pr: status to review To notify reviewers to review this pull-request labels Aug 28, 2020
@guparan guparan added this to the v20.12 milestone Nov 17, 2020
@guparan guparan changed the title [all] Accelerating CMake generation [All] Accelerating CMake generation Jan 18, 2021
bakpaul pushed a commit to bakpaul/sofa that referenced this pull request Feb 23, 2024
* [SofaMacro] Add the protecting guard & a new @PACKAGE_GUARD@ for .in

* [all] Add protecting guard in every .cmake file

* [all] Add @PACKAGE_GUARD@ in every .in file so it is expanded to a fully working guard.

* [all] Add in every cmake.in the macro @PACKAGE_GUARD@

To keep cmake generation time low.

* [all] Use the CMake include_guard() instead of our custom version.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement About a possible enhancement pr: fast merge Minor change that can be merged without waiting for the 7 review days pr: status ready Approved a pull-request, ready to be squashed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants