[ccache] cache coherency across multiple users
wsnyder at wsnyder.org
Fri Apr 1 13:36:36 MDT 2011
>A quick question: man page suggests that it is possible to share ccache across
>multiple developers by following a set of rules for permissions, umask and
>setting up of ccache dirs env vars etc. What it doesn't talk about is what
>happens if two developers are compiling at the same time and there is a cache
>miss and ccache needs to write the newly created object to the ccache directory.
>What happens to two (or more) write calls arriving at the same time? Is there
>some sort of locking in place to avoid getting garbage in the resultant object
>What about the case where one gets a hit and wants to read while the other gets
>a miss and wants to overwrite the object with the new object file?
>And the case, where cache size management needs to throw away an existing object
>file to replace with another object file? Another developer's run may be reading
>it while this run is throwing it away.
Many companies are using it this way now.
All of these cases are handled correctly by using the atomic
file system rename() calls. An observer will never see
partial state, only a correct file or nothing. There's even
further protection if you enable gzip compressed objects of
a CRC check.
More information about the ccache