[darcs-devel] [patch1162] resolve issue1624: bucketed cache.

Guillaume Hoffmann bugs at darcs.net
Tue Jun 24 19:06:47 UTC 2014


Guillaume Hoffmann <guillaumh at gmail.com> added the comment:

Nice.

* GZCRCs: please remove these changes, they belong to another patch.
* Repository.hs: ok, adapting the code of tar unpacking
* Prefs: ok
* HashedRepo: ok

* Cache.hs:

the fact that we have both functions hashedFilePath and
hashedFilePathOld is a little hard to understand.

Two options: 1) Call the second one hashedFilePathReadOnly, and in the
first case of its definition add a comment like:

    -- if directory, assume it is non-bucketed cache (old cache location)

2) An alternative, maybe cleaner, is to add a third constructor to
CacheType, say DirectoryOld or DirectoryNonBucketed, make the function
getCaches use this constructor for the variable `oldGlobalcache` and
only have one function hashedFilePath (and do without hashedFilePathOld).

Now as you said, with your patch, files found in the old (non-bucketed)
location get automatically hard-linked into the new (bucketed) cache
location when they get accessed. This happens since darcs systematically
copies files from non-writable sources to writable sources. I guess the
logic is that a typical non-writable source is a remote repository
accessible by HTTP, and you want that files to be copied locally to the
cache.

It's not bad actually, since hard linking files does not use more space
on the hard drive and this makes the local caches more robust to
deleting the old cache directory. So I think it's good.

The only caveat I have is to make sure the function
fetchFileUsingCachePrivate does not systematically look into the old
cache *before* the new cache, otherwise its files will get linked over
and over again to the new cache. I'd update the function
`compareByLocality` with an extra case to compare writeability of cache
sources and ensure local writable < local non-writable.

As for `darcs optimize bucketed`, I'd simply call it `darcs optimize
cache`. Moreover you should make it more robust to the absence of either
inventories / pristine.hashed / patches subdirectories of ~/.darcs/cache
(currently it throws you an error).

Finally, for Windows, you should make that APPDATA\darcs\cache (I think
that's it) be considered as the old nonbucketed cache and
APPDATA\darcs\cache2 the new bucketed one.

__________________________________
Darcs bug tracker <bugs at darcs.net>
<http://bugs.darcs.net/patch1162>
__________________________________


More information about the darcs-devel mailing list