Re: does ccache include source code modified time into hash?
Joel Rosdahl <[email protected]> Wed, 12 Nov 2014 21:22:43 +0100
| Newsgroups | gmane.comp.compilers.ccache |
|---|---|
| Message-ID | <CAK8D=piipDno93jM3YLisCZwTzPAkYd9Z+=PibrcT=Fnh3uNuA@mail.gmail.com> |
Hi Makson, Since the manual wasn't clear enough, what kind of information do you think would be good to add to the "How ccache works" section? Suggestions are very welcome. -- Joel On 12 November 2014 02:26, Makson Lee <[email protected]> wrote: > Hi Guys, > > Yes, it did help, thanks for the detailed explanation. > > 2014-11-12 1:33 GMT+08:00 Andrew Stubbs <[email protected]>: > > > On 11/11/14 15:11, Makson Lee wrote: > > > >> i am not sure that whether ccache will re-compile source code if we just > >> change the modified time of it, can not find much about the details of > >> "how > >> ccache works", in the manual, it just says that ccache will hash the > >> source > >> code, but what kinds of information of source code are hashed? > >> > > > > Ccache has two modes: "direct mode" and "preprocessor mode". It tries > > both, in that order. > > > > Preprocessor mode is the slower, older mode. This does not pay any > > attention to the file stats. It simply runs the compiler preprocessor and > > sees if the MD4 hash of the output matches something it has seen before. > In > > theory, you can even edit the comments and macro text, to some degree, > and > > still get a cache hit. > > > > Direct mode is much faster, but less tolerant of irrelevant changes. In > > this mode, ccache keeps a cache ("manifest") of every source file used > by a > > compile, including times, size, and an MD4 hash. It then tries to match > > each file and determine if the source matches without calling the > compiler > > at all. Ordinarily, it uses only the MD4 hash to determine this, so > > changing the mtime will have no effect. > > > > However, if you set "CACHE_SLOPPINESS=file_stat_matches" then direct mode > > will ignore the contents of the source files, and determine similarity > > using only the ctime, mtime, and size attributes. In this case, changing > > the mtime will cause a direct mode cache miss. Ccache will then fall-back > > to preprocessor mode, and you should still get a cache hit that way, > albeit > > slower. The cached manifest will be updated, and the next time you build > > you will get a direct mode cache hit again, unless the mtime changes > again. > > > > Hope that helps > > > > Andrew > > > _______________________________________________ > ccache mailing list > [email protected] > https://lists.samba.org/mailman/listinfo/ccache >