[ccache] basename of source file in hashed name in ccache

Joel Rosdahl joel at rosdahl.net
Wed Nov 9 13:52:39 MST 2011

On 9 November 2011 18:46, Frank Klotz <frank.klotz at alcatel-lucent.com> wrote:
> On 11/08/2011 11:08 PM, Joel Rosdahl wrote:
>> I don't think you can in an acceptable way find an existing file to reuse
>> when you're about to store a new file -- you'll have to list the directory
>> and iterate through its items to look for a reusable file. (That is, unless
>> you introduce some kind of higher-level index that makes it possible to
>> efficiently list existing files with a given hash.)
> Maybe I'm confused again, but since they have the same hash hhh, wouldn't it
> in fact be trivially EASY to find them?

Easy: yes. Fast: no.

> The subdirectory selection still depends on the hash, so both files would be
> in the same directory, and when you are looking to create hhh.foo.o in that
> directory, you can first look for hhh.*.o, and when you find hhh.bar.o [...]

To look for hhh.*.o in directory D, you need to get a directory listing of D
and iterate through its items (i.e., file names) and see if they match the
pattern. This will be expensive for directories with many files.

-- Joel

More information about the ccache mailing list