Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 156865 - ccache statistics are broken
Summary: ccache statistics are broken
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Unclassified (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks: 147007
  Show dependency tree
 
Reported: 2006-12-01 20:24 UTC by Ryan Hill (RETIRED)
Modified: 2007-01-13 06:44 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
portage-ccache-doc.diff (portage-ccache-doc.diff,2.72 KB, patch)
2007-01-01 16:29 UTC, Ryan Hill (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan Hill (RETIRED) gentoo-dev 2006-12-01 20:24:31 UTC
'man make.conf' has this to say about FEATURES=ccache:

    Enable portage support for the ccache package.  If the ccache dir is not
    present in the user's environment,  then portage will default to
    ${PORTAGE_TMPDIR}/ccache (with userpriv) and to /root/.ccache otherwise.

But if ${CCACHE_DIR} is not in the environment, ebuild.sh will set ${CCACHE_DIR} to /var/tmp/ccache regardless of FEATURES=userpriv.  I actually think /var/tmp/ccache is a far saner location in both cases (who wants >1GiB of cache data on their root partition?), but a problem arises with the ccache's statistics reporting.

ccache defaults to /root/.ccache when ${CCACHE_DIR} isn't set.  Portage defaults to /var/tmp/ccache.  So, when you run 'ccache -s' it'll report the statistics from the /root cache and not the /var/tmp cache that's actually being used.  The result is stats that never update.

One way to fix this is to make sure ${CCACHE_DIR} is always set somewhere in the environment (/etc/env.d?).  Another way is to go back to the documented behaviour, but I think I'd rather blow a goat.  We need a way to make 'ccache -s' work with FEATURES=userpriv anyways.
Comment 1 Jakub Moc (RETIRED) gentoo-dev 2006-12-02 04:25:44 UTC
CCACHE_DIR=/var/tmp/ccache ccache -s too difficult to figure out, or? Kinda miss what does this have to do w/ portage...
Comment 2 Marius Mauch (RETIRED) gentoo-dev 2006-12-02 12:48:58 UTC
At most a doc bug I'd say (env.d is a no go).
Comment 3 Lisa Seelye (RETIRED) gentoo-dev 2006-12-02 20:58:00 UTC
$CCACHE_DIR defaults to $HOME/.ccache if it is not set. Since `emerge' is invoked by root in normal circumstances $CCACHE_DIR will be set to $HOME/.ccache when userpriv isn't set.

This is normal and expected behaviour. Without userpriv the user is compiling as root and the ccache is root's.

With userpriv the user is compiling as `portage' and the ccache belongs to the portage user.  As such to check the ccache stats for the portage user one must set the CCACHE_DIR envvar to whatever portage's $HOME/.ccache is or whatever $CCACHE_DIR is set to in /etc/make.conf.

This is not a 'bug' and if this was assigned to me I'd mark it invalid with a note to the poster to remember what user is compiling with regards to userpriv.
Comment 4 Ryan Hill (RETIRED) gentoo-dev 2006-12-03 00:54:57 UTC
Sorry, I wasn't very clear (lack of sleep)

(In reply to comment #3)
> $CCACHE_DIR defaults to $HOME/.ccache if it is not set. Since `emerge' is
> invoked by root in normal circumstances $CCACHE_DIR will be set to
> $HOME/.ccache when userpriv isn't set.
> 
> This is normal and expected behaviour. Without userpriv the user is compiling
> as root and the ccache is root's.

Right, so without userpriv the cache should go into /root/.ccache, which is what the documentation says as well.  But portage doesn't actually check for userpriv, and just dumps it into /var/tmp/ccache regardless.

ebuild.sh:
1381     if hasq ccache ${FEATURES} ; then
1382         #We can enable compiler cache support
1383         if [ -z "${PATH/*ccache*/}" ]; then
1384             # Remove the other reference.
1385             remove_path_entry "ccache"
1386         fi
1387
1388         if [ -d /usr/lib/ccache/bin ]; then
1389             export PATH="/usr/lib/ccache/bin:${PATH}"
1390         elif [ -d /usr/bin/ccache ]; then
1391             export PATH="/usr/bin/ccache:${PATH}"
1392         fi
1393
1394         [ -z "${CCACHE_DIR}" ] && export CCACHE_DIR="/var/tmp/ccache"
1395
1396         addread "${CCACHE_DIR}"
1397         addwrite "${CCACHE_DIR}"
1398
1399         [ -n "${CCACHE_SIZE}" ] && ccache -M ${CCACHE_SIZE} &> /dev/null
1400     fi

which is why this is either a portage bug or a portage documentation bug. ;)  I noticed it's mentioned in make.conf.example as well but a little vague on the details.

(In reply to comment #1)
> CCACHE_DIR=/var/tmp/ccache ccache -s too difficult to figure out, or?

Apparently.  I answer this question every month or so on the forums. ;P

Whatever the outcome, I'd like to submit a doc patch to clarify things a bit and maybe save some of the confusion users are having.
Comment 5 Jakub Moc (RETIRED) gentoo-dev 2007-01-01 12:15:38 UTC
(In reply to comment #4)
> Right, so without userpriv the cache should go into /root/.ccache, which is
> what the documentation says as well.  But portage doesn't actually check for
> userpriv, and just dumps it into /var/tmp/ccache regardless.

Uh no, portage just plain shouldn't touch /root at all...
Comment 6 Ryan Hill (RETIRED) gentoo-dev 2007-01-01 16:29:59 UTC
Created attachment 105117 [details, diff]
portage-ccache-doc.diff

then it's the documentation.

what do you think of something like this?  does make.conf.txt need to be changed too?
Comment 7 Jakub Moc (RETIRED) gentoo-dev 2007-01-06 15:46:16 UTC
(In reply to comment #6)

Yeah, really ccache should only stick stuff into ~/.ccache with non-portage compiles. 

Comment 8 Marius Mauch (RETIRED) gentoo-dev 2007-01-11 07:10:47 UTC
Patch applied in trunk, thanks.
Comment 9 Zac Medico gentoo-dev 2007-01-13 06:44:54 UTC
This is in svn r5543 and has been released in 2.1.2_rc4-r9.