-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Adding possibility of faster builds using ccache #3381
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can give this a try on Ubuntu, though I don't have experience with ccache
. Do we expect shorter first-time compilations?
Most likely, no. Unless the compiler for some reason doesn't reuse the compiled object (which can happen based on CMake generation and rules) I do forsee developers getting faster recompiles after branch changes (or if they have 2 different versions in 2 different locations). Plus, if ccache is shared between CI, then the CI builds will also be faster (lots of reasons to start a clean build every time and not share the build dir) |
I get endless warnings of this kind:
|
I see. Your output seems to be truncated
Could you report the command by setting |
Yep. And then a warning from the next file comes
I checked the contents of the launch files and the problem is clear: With this fix everything works. |
Of course. That'll bite me. I use bash as my driver, not dash (not Ubuntu). Could you push your fix? I'll have to test and fiddle with bracket expressions. |
Thanks. That was trivial (and the bash test macro was useless) |
Just as note: We are using it in our project, too, but our way is a lot of easier:
I'm using ccache already since month for PCL via:
But in general: CCache should be default to Further note: For MSVC clcache exists. //Edit: Ah well, now I see, why it looks so complicated compared to our short solution. |
Thanks. It's interface is almost a mirror too. I added some modification for MSVC based on this |
I found this document for instructions to use ccache for azure pipelines. This should being down CI build times by a lot. On my system, ccache takes 6.1 GB space. $ ninja clean; time ninja
real 1m7.459s
user 4m57.092s
sys 0m42.055s |
I will rebuild and push the |
Is pip or chocolatey available for installing clcache on Windows machines? @SunBlack have you used clcache before? Should there be something specific to clcache (compared to ccache)? |
Here is the Windows image contents. Chocolatey is the first item on the list. After adding
*compared to pre-ccache jobs where the build step took around 1:50. If the entire job duration (including upload/download of cache) is taken into account, then the time is even approximately 10 minutes worse. |
We are using clcache on our Build server on this way (without CMake):
Thinks you should know about clcache:
|
This is really high and perhaps due to insufficient cache (and also since the second run was worse compared to the first) EDIT: The cache misses are still huge, which I'm hoping will be resolved by a step to zero the stats before every build so we get per-build data, not accumulated. |
3181dfe
to
2bbc00d
Compare
Wow, that's great. Now I am convinced :) However, I tend to agree with @SunBlack regarding the default state:
|
Try to compile on your workstation and feel the difference already 😛
PTAL at the recent rebase. I've applied the ON to We could tune this more (for Mac too), with slopiness for Experimenting on the CI has a severe lag of 😰 for every tiny modification. Esp since Windows takes 2 hours to build. Any ideas on how to test? I don't have access to Azure free anymore |
My workstation has 24 threads, so PCL is built in no time anyway 😛
I overlooked that, indeed. But then I will bring my proposal to rename to
I added you to the Azure organization a couple of days ago, so you should be able to cancel/reschedule jobs. |
choco install clcache --source=. | ||
- task: CacheBeta@0 | ||
inputs: | ||
key: ccache | msvc | $(Agent.OS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we have different keys for x86 and x64 jobs? Or is it okay to mix their caches?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the platform is different so would the $(Agent.OS)
string, but that's not what happened. I don't know if it'll work, but I'll push a change with the GENERATOR variable as part of the cache string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a step that prints all environment variables. Looking at it, I think it would be appropriate to append Agent.OSArchitecture
to the key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, and no, it's not ok. Not an issue since the cache is fortunately for reasons unknown to me empty. Maybe clcache doesn't want the command to include the compiler .... 🤷♂
With the latest change we have different keys for different jobs, that's good. But it seems like
If you think about it, this is of no surprise since compiler launcher properties are only supported for Ninja and Makefiles, not MSVC. According to this page the only way to use |
One other thing. I found this implementation, also based on the blog post you referenced. In comparison to the scripts in this PR it:
What're your feelings about adopting it? |
Yay
Overall positive but somewhat mixed feelings. ✅ On one hand, one single file. 🔻 On the other hand, CMake isn't sh and it looks bad. But it works ¯\_(ツ)_/¯ ✅ And we can just copy-paste and edit to add the link to the original till KDE lives 😆
That's the truly sad part of this entire chain 😆
Are we running in powershell or what? I don't know what syntax to use to set the env variable |
Try to add the following step before CMake configuration:
Same here. Not sure if not having separate files is a big plus. So I'll leave it up to you to decide. But at any rate, copy over the CUDA part. |
Single file. Least headache. Also, since the setting is done globally for clcache, I'll create a warning saying: Set the CXX/C env variable, since clcache doesn't behave like ccache. |
This I don't get. To enable |
This didn't seem to work as evident by CMake config log
Also, I've changed the file contents. PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, setting the environment variable does not help. What about leaving Windows CI support out of this pull request for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, wrong button.
I'll try to push a change today or tomorrow. Really wanted to reduce Windows build time down to 1 hour or so from 2 hours |
Sure, if you haven't run out of ideas yet, let's keep on trying. |
I gave up after another experiment on Windows. Unnoticed to me, the change to new script resulted in ccache not being used. I'm working on it. |
Ignore MSVC + Recommended change Replace [[ with [ to be compatible with sh Fix indentation disable ccache by default Add clcache support Modifications to save variables in parent scope
Setting a high limit on cache size Per-run stats only Removed ccache from Mac, negative performance impact
PTAL. Works on Mac, Ubuntu and Arch. On the CI, enabled only for ubuntu 16.04 Build time ~1 hour on Ubuntu CI |
This is a great contribution, thanks for working on it. |
Compile times should be shorter now
This solution should work for Unix Makefile, Ninja and XCode. It'll not work for MSVC since ccache doesn't support it.
There may be need for changing the
${PCL_DISABLE_CCACHE}
if MSVC is used (when ccache is installed), but it'll need testing. Any volunteers?