Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] problem using ccache........
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
mikefot
l33t
l33t


Joined: 19 Nov 2014
Posts: 709

PostPosted: Wed Dec 06, 2017 1:43 pm    Post subject: [SOLVED] problem using ccache........ Reply with quote

Dear Folks,

I installed ccache.

I think it is working because the no of files int he cache are increasing etc.

Code:
djt /home/mikef # !493
CCACHE_DIR="/var/tmp/ccache" ccache -s
cache directory                     /var/tmp/ccache
primary config                      /var/tmp/ccache/ccache.conf
secondary config      (readonly)    /etc/ccache.conf
cache hit (direct)                  1757
cache hit (preprocessed)             267
cache miss                          3696
called for link                      771
called for preprocessing             226
compile failed                        59
preprocessor error                    36
bad compiler arguments                27
unsupported source language            7
autoconf compile/link                485
no input file                        425
files in cache                      9061
cache size                         325.1 MB
max cache size                       2.0 GB



The problem is that the compile times seem to stay constant and there seems to be no benefit from ccache.

The documentation says that if you ARE NOT using portage then you would specify the path as follows:

Code:
FILE ~/.bash_profileSetting the ccache location before any other PATH

PATH="/usr/lib/ccache/bin:${PATH}"



But I am using emerge and so I think that means I am using portage so I don't need to specify the path in this way.

Am I doing something wrong here.

The kaveri box I am using is supposed to have 8GB of RAM in it.

I would appreciate a suggestion of a command I can run to check that there is 8GB of active RAM running here on my system.

There should be.


Comments appreciated.

Michael Fothergill


Last edited by mikefot on Fri Dec 15, 2017 9:17 pm; edited 1 time in total
Back to top
View user's profile Send private message
mikefot
l33t
l33t


Joined: 19 Nov 2014
Posts: 709

PostPosted: Wed Dec 06, 2017 6:18 pm    Post subject: I suspect it's a permissions problem... Reply with quote

Dear All,

I have been googling around and found some suggestions that I might need to change the permissions on the directories where the ccache files are stored.

Apparently the FEATURES beastie thinks the permissions are set a user level so it would be blocked entering directories set with root permissions.

Also the cache data can be stored in a root tree directory somewhere as well as in /var/tmp or wherever and some confusion can occur over which one is visited and used as well........

I will try some chmod chown and chgrp commands etc and see how I get on.

Regards

MF
Back to top
View user's profile Send private message
Irre
Guru
Guru


Joined: 09 Nov 2013
Posts: 434
Location: Stockholm

PostPosted: Wed Dec 06, 2017 6:26 pm    Post subject: Reply with quote

When rebuilding same packages compile times are often much faster than first time (but not always).

With 8g RAM you can also allocate /var/tmp to tmpfs. In /etc/fstab:

tmpfs /var/tmp tmpfs size=4g,nosuid,nodev 0 0


BUT ccache must not be in tmpfs!
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6747

PostPosted: Wed Dec 06, 2017 6:33 pm    Post subject: Re: problem using ccache........ Reply with quote

mikefot wrote:
The problem is that the compile times seem to stay constant and there seems to be no benefit from ccache.

Your hit rate is not so bad. But whether ccache saves time (and how much) depends a lot of the type of files which are hit. Usually, for C++ files the gain is enormous while for C files it is almost negligible.
Back to top
View user's profile Send private message
mikefot
l33t
l33t


Joined: 19 Nov 2014
Posts: 709

PostPosted: Wed Dec 06, 2017 7:03 pm    Post subject: a few extra points on ccache.... Reply with quote

Many thanks for the responses.

If you look here:

https://forums.gentoo.org/viewtopic-t-1064518-start-0.html

then permissions and reading and writing of files do seem to be a bit of a vulnerability here.

But I think writing to the cache and probably reading from it to aid a second compilation IS actually occurring in my case now and maybe I don't need to play around with chmod, chown and chgrp etc............

This is also helpful:

http://wikigentoo.ksiezyc.pl/Ccache.htm

A suggestion of a package that ought to be speeded up a lot by ccache that I could test would be helpful.

Cheers

MF
Back to top
View user's profile Send private message
mikefot
l33t
l33t


Joined: 19 Nov 2014
Posts: 709

PostPosted: Wed Dec 06, 2017 7:14 pm    Post subject: ccache test bench... Reply with quote

How about
Code:
sportage-0.9.3 subproject
?

Should be plenty of C++ code in that one surely?

Regards

MF
Back to top
View user's profile Send private message
mikefot
l33t
l33t


Joined: 19 Nov 2014
Posts: 709

PostPosted: Wed Dec 06, 2017 8:30 pm    Post subject: ccache Reply with quote

Dear All,

I will run with ccache for a while (2 months)

If I can't see any signs of serious speed up in compile times in a range of packages I will uninstall it and abandon it.

Cheers

MF
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21635

PostPosted: Thu Dec 07, 2017 1:34 am    Post subject: Reply with quote

You only get a cache hit if ccache determines that reusing the cached file will produce the same result as compiling the input again. Some packages may have irrelevant but technically meaningful changes across rebuilds, which would prevent otherwise valid cache hits. For example, if the configure script writes a header that contains a string that varies with each run of configure, any source files that include that header will always miss the cache, even if in practice you don't care about that string being reused instead of rebuilt.
Back to top
View user's profile Send private message
mikefot
l33t
l33t


Joined: 19 Nov 2014
Posts: 709

PostPosted: Thu Dec 07, 2017 12:25 pm    Post subject: compiling gcc itself should be a good test of ccache....? Reply with quote

Dear Folks,

A great many thanks for the comments provided so far.

I found a post that says that gcc is mostly written in C++ nowadays......

Quote:
Since 4.8 release, the C++ compiler GCC (the G++ part of it) is written not in C anymore, but in C++ itself. ... I wonder how to compile the C++ code of GCC on a new platform that has no C++ compiler yet. Of course, you could use prebuilt binaries compiled on other machines.12 Dec 2014
Isn't there a chicken-and-egg issue since GCC is written in C++ itself?
https://softwareengineering.stackexchange.com/.../isnt-there-a-chicken-and-egg-issue-sin...


So I am going to re emerge gcc and then repeat it and see if there is any gain from ccache.

If not, ccache will be uninstalled promptly.

Comments appreciated.

Regards

MF
Back to top
View user's profile Send private message
mikefot
l33t
l33t


Joined: 19 Nov 2014
Posts: 709

PostPosted: Thu Dec 07, 2017 12:34 pm    Post subject: gcc compilation test first run... Reply with quote

Dear All,

I have started the first compilation run on gcc.

Here is the output of genelop on it:

Code:
every 10.0s: genlop -ci                                                                                                                                djt: Thu Dec  7 12:29:20 2017


 Currently merging 1 out of 1

 * sys-devel/gcc-6.4.0

       current merge time: 25 seconds.
       ETA: 49 minutes and 29 seconds.

I will post the actual execution time, and then the output of ccache etc and start the second run.

Regards

MF
Back to top
View user's profile Send private message
mikefot
l33t
l33t


Joined: 19 Nov 2014
Posts: 709

PostPosted: Thu Dec 07, 2017 1:21 pm    Post subject: I have registered on the ccache mailing list... Reply with quote

Dear All,

I have registered on the ccache mailing list.

I am going to see if anyone there can help with this.

Regards

MF
Back to top
View user's profile Send private message
mikefot
l33t
l33t


Joined: 19 Nov 2014
Posts: 709

PostPosted: Thu Dec 07, 2017 1:36 pm    Post subject: ccache output after first run of gcc compilation.. Reply with quote

Dear All,

The first run of gcc compilation has finished.

Here is the ccache output:



Code:
djt /home/mikef # !472
CCACHE_DIR="/var/tmp/ccache" ccache -s
cache directory                     /var/tmp/ccache
primary config                      /var/tmp/ccache/ccache.conf
secondary config      (readonly)    /etc/ccache.conf
cache hit (direct)                 12901
cache hit (preprocessed)             423
cache miss                         15069
called for link                     2092
called for preprocessing            1524
multiple source files                  4
compile failed                       128
preprocessor error                    50
bad compiler arguments                57
unsupported source language         2273
autoconf compile/link                987
unsupported compiler option            8
no input file                       2536
files in cache                     41703
cache size                         777.9 MB
max cache size                       2.0 GB


I will try recompiling it again see if the compile time is reduced by much.

Comments appreciated.
Back to top
View user's profile Send private message
mikefot
l33t
l33t


Joined: 19 Nov 2014
Posts: 709

PostPosted: Thu Dec 07, 2017 1:46 pm    Post subject: I started the second compilation run on gcc.... Reply with quote

Dear Folks:

I have started the second compilation of gcc again.

Here is the output of genlop after 5 minutes:


Code:
Every 10.0s: genlop -ci                                djt: Thu Dec  7 13:44:07 2017


 Currently merging 1 out of 1

 * sys-devel/gcc-6.4.0

       current merge time: 5 minutes and 48 seconds.
       ETA: 44 minutes and 29 seconds.



It doesn't look like it's helping at all here.

Regards

MF
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Thu Dec 07, 2017 2:58 pm    Post subject: Reply with quote

you should really know ccache is a dev tool more than an user tool, it will act good only if you rebuild something very similar (which imply cache hit), so for a gentoo user it mostly mean ccache will be of help for: a package that is revbump (going from -r1 to -r2), or a package that is rebuild for useflag change (however useflag change can lead to a way too much different code and cache miss).
it should also help a lot with autorebuild asked by portage, but in this case, it will in real mostly act bad ; if portage set r or R on the package it is because some other package has change and trigger the rebuild ; and in this case, you should not reuse cache hit, as you must not end with the same code finally ; if ccache hit and use old code, it will mostly void the r/R portage was forcing for a reason.

for gcc, it's because of its nature that ccache is doing bad: gcc is not building as-is, gcc build xgcc with sane default optimization and cflags, than xgcc will build the final gcc with your cflags and optimization set. While ccache may store the xgcc code for futher cache hit, when xgcc finally build gcc the code is than different (it now use your optimization) leading to cache miss ; and if ccache goes hit, again it will do wrong, as it will reinject code built for xgcc in your final gcc step (which remove xgcc optimization on gcc code).

if you know what you do and when/why ccache could lead to sneaky errors, maybe ccache could be really of help, but i would define this case only for devs and some users who handle it like it should (which doesn't mean just having portage handle it and thinking it will do good).
for most users, it mean strange compile errors and weird behaviour ; and if you have any trouble, first thing people will tell you: rebuild with ccache disable.
ccache is a good dev tool, but for user, a bad tool that when misuse will do more trouble than help.

most of the time (for a user), the case where you could use ccache with high efficiency with portage also mean you could had use binary of the package, and ccache couldn't beat binary emerge time.

i won't make friend again with ccache fans, but really the only sane rule with ccache should be: if it's to use it only with portage, it mean you should not use it.
Back to top
View user's profile Send private message
xaviermiller
Bodhisattva
Bodhisattva


Joined: 23 Jul 2004
Posts: 8708
Location: ~Brussels - Belgique

PostPosted: Thu Dec 07, 2017 3:14 pm    Post subject: Reply with quote

https://blog.flameeyes.eu/2010/07/debunking-ccache-myths-redux/
https://blog.flameeyes.eu/2008/06/debunking-ccache-myths/
_________________
Kind regards,
Xavier Miller
Back to top
View user's profile Send private message
mikefot
l33t
l33t


Joined: 19 Nov 2014
Posts: 709

PostPosted: Thu Dec 07, 2017 7:04 pm    Post subject: I upgraded to ccache 3.3.4 from 3.2.4..... Reply with quote

Dear Folks,

I upgraded to ccache 3.3.4 from 3.2.4.....

I think there were some bugs in 3.2.4 that might have been a problem......

I also seem to have
Code:
sys/devel-distcc
installed.

There is an extra command I need to have turned on to make the two packages work together properly.

I will try to fix this.

MF
Back to top
View user's profile Send private message
mikefot
l33t
l33t


Joined: 19 Nov 2014
Posts: 709

PostPosted: Thu Dec 07, 2017 7:35 pm    Post subject: I have uninstalled distcc Reply with quote

Dear Folks,

Ihave uninstalled distcc.

It was not set up any way.

Regards

MF
Back to top
View user's profile Send private message
mikefot
l33t
l33t


Joined: 19 Nov 2014
Posts: 709

PostPosted: Thu Dec 07, 2017 7:51 pm    Post subject: I think ccache is starting to work a bit Reply with quote

Dear Folks,

I think ccache is starting to work a bit.

It is finishing compilations (if you sit through them) in a shorter time than genlop eta predicts on the second run.......

It does work.

I noticed on the ccache samba site that they mention something called cachecc1 which is meant to be a gcc cache ie it would speed up the compilation of gcc itself.

as I now know a gcc compilation takes 45 minutes on this kaveri box here.

If I would uninstall ccache here and manually install cachecc1 (using a make command or something - there is no gentoo package for cachecc1 AFAICT) I could compare it.

There is also a program called AO written by IBM I think that looks interesting but again there is no gentoo package for it.

Comments appreciated.
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6747

PostPosted: Thu Dec 07, 2017 8:28 pm    Post subject: Re: compiling gcc itself should be a good test of ccache.... Reply with quote

mikefot wrote:
emerge gcc and then repeat it

Using gcc cannot serve as a benchmark for ccache:
If the compiler changes, the cached files are worthless.
When gcc bootstraps, the compiler changes 3 times.
And on the next run, your compiler has changed again, so you will get the same timing. (For ccache the compiler is already different if it has a different date).

Examples of packages which are good benachmarks for ccache are chromium, libreoffice, the qt packages etc.
For instance, for chromium the compile time here decreases from 16 hours to 30 minutes for a second emerge.
In practice this means if I have to recompile because a minor library changed (which does not involve too many flies). it already saved me about 1 day just in this example.
Back to top
View user's profile Send private message
mikefot
l33t
l33t


Joined: 19 Nov 2014
Posts: 709

PostPosted: Thu Dec 07, 2017 10:43 pm    Post subject: trying ccache out on qtwebengine Reply with quote

Dear All,

Many thanks for the tips and hints here.

What I am hearing hear is that ccache is actually OK for my purposes here relative to other compiler optimisers etc.

I am now compiling qtwebengine ETA 1 hr 41 minutes according to genlop for the first time around.

There is now 15 minutes to go left.

I will then run it again and see how I get on.

Regards

MF
Back to top
View user's profile Send private message
mikefot
l33t
l33t


Joined: 19 Nov 2014
Posts: 709

PostPosted: Thu Dec 07, 2017 11:23 pm    Post subject: qtwebengine 1st compile result Reply with quote

Dear All,

The compile time for qtwebengine was 2 hours 5 mins or so for the first run.

Code:
djt /home/mikef # CCACHE_DIR="/var/tmp/ccache" ccache -s
cache directory                     /var/tmp/ccache
primary config                      /var/tmp/ccache/ccache.conf
secondary config      (readonly)    /etc/ccache.conf
cache hit (direct)                 22820
cache hit (preprocessed)             571
cache miss                         36348
cache hit rate                     39.16 %
called for link                     3946
called for preprocessing            2956
multiple source files                  8
compile failed                       255
preprocessor error                    99
bad compiler arguments               112
unsupported source language         4539
autoconf compile/link               1923
unsupported compiler option           16
no input file                       4690
cleanups performed                     5
files in cache                    101369
cache size                           1.8 GB
max cache size                       2.0 GB
djt /home/mikef #


I am now starting the second run.
Back to top
View user's profile Send private message
mikefot
l33t
l33t


Joined: 19 Nov 2014
Posts: 709

PostPosted: Thu Dec 07, 2017 11:31 pm    Post subject: second run qtwebengine ccache result.... Reply with quote

Dear All,

It compiled qtwebengine the second time in 5 minutes flat............!

ccache works.

Regards

MF
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21635

PostPosted: Fri Dec 08, 2017 1:38 am    Post subject: Reply with quote

krinn wrote:
if ccache hit and use old code, it will mostly void the r/R portage was forcing for a reason.
I agree with most of your post, but want to offer a counterpoint on this. Since ccache works on the translation unit level, not the package level, you could plausibly get valid cache hits on parts of the package that are insensitive to the reason that Portage forced a rebuild, but then get cache misses for the portions that are sensitive to the change. For example, in the case of wget, if the user installs a new OpenSSL with a differing ABI, an https-aware wget would need to be rebuilt. However, only the portions of wget that interact with OpenSSL need to be different. Its DNS and TCP code, and its HTTP parser/writer, should be unaware of OpenSSL and should be eligible for a ccache hit.
Back to top
View user's profile Send private message
mikefot
l33t
l33t


Joined: 19 Nov 2014
Posts: 709

PostPosted: Fri Dec 08, 2017 9:59 am    Post subject: emerging libreoffice with ccache... Reply with quote

Dear All,

I emerged libreoffice under ccache and it took around 2hrs 2 mins on the first run.

I am now making the second compilation.

Regards

MF
Back to top
View user's profile Send private message
mikefot
l33t
l33t


Joined: 19 Nov 2014
Posts: 709

PostPosted: Fri Dec 08, 2017 10:09 am    Post subject: result of second compilation of libreoffice with ccache Reply with quote

Dear All,

The second compilation has taken about 5 minutes or so again.

I am impressed.

MF
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum