darcs

Patch 2146 make hashed pristine use the cache

Title make hashed pristine use the cache
Superseder Nosy List bfrk
Related Issues
Status accepted Assigned To
Milestone

Created on 2021-01-10.14:53:11 by bfrk, last changed 2021-03-28.21:53:40 by bfrk.

Files
File name Status Uploaded Type Edit Remove
factor-readrecorded-into-darcs_repository_pristine_readpristine.dpatch bfrk, 2021-01-10.14:53:09 application/x-darcs-patch
fix-haddocks-for-fscreatehashedfile.dpatch bfrk, 2021-03-28.21:53:40 application/x-darcs-patch
patch-preview.txt bfrk, 2021-01-10.14:53:09 text/x-darcs-patch
patch-preview.txt bfrk, 2021-03-28.21:53:40 text/x-darcs-patch
unnamed bfrk, 2021-01-10.14:53:09 text/plain
unnamed bfrk, 2021-03-28.21:53:40 text/plain
See mailing list archives for discussion on individual patches.
Messages
msg22618 (view) Author: bfrk Date: 2021-01-10.14:53:09
The main goal here is the last patch: to make use of the cache when handling
pristine files, bringing them on par with how we handle patches and
inventories. The rest are dependencies.

8 patches for repository http://darcs.net/screened:

patch 8ca83d6865ef69166b77bd87fcb01f95d2c6ef6d
Author: Ben Franksen <ben.franksen@online.de>
Date:   Thu Nov  5 16:36:44 CET 2020
  * factor readRecorded into Darcs.Repository.Pristine.readPristine

patch 665fe08d512eb525283e130f51bf3889812c1ed9
Author: Ben Franksen <ben.franksen@online.de>
Date:   Thu Nov  5 16:50:02 CET 2020
  * readHashedPristineRoot: fail with oldRepoFailMsg instead of returning Nothing

patch 6ece1acdbc944bd6a3fad7c538ea26c89f203cb7
Author: Ben Franksen <ben.franksen@online.de>
Date:   Fri Nov  6 10:31:57 CET 2020
  * some cleanup in D.R.Repair
  
  The only non-obvious change here is that we no longer test if we are in a
  hashed repo in cleanupRepositoryReplay. But darcs check and darcs repair
  refuse to work on oldfashioned repos anyway.

patch 4ae470b13facd99e34af8acc775a5750c314bb6c
Author: Ben Franksen <ben.franksen@online.de>
Date:   Sun Nov  8 08:28:28 CET 2020
  * cleanup: remove createPartialsPristineDirectoryTree
  
  The only remaining call site was in the dist command where we have no need
  to create a partial tree. As a result we can also remove copyPartialHashed
  and copyPartialsHashed from HashedIO.

patch 4e3995fbffa1f9b5eb35124b02e4de595b806e6e
Author: Ben Franksen <ben.franksen@online.de>
Date:   Thu Nov  5 14:46:15 CET 2020
  * cleanup: inline copyPristineDirectoryTree

patch ba61025d2aa7f3dc0f0cfc9efb8452bead685e04
Author: Ben Franksen <ben.franksen@online.de>
Date:   Sun Nov  8 14:22:44 CET 2020
  * specialize cleanHashdir to cleanPristineDir
  
  It makes no sense to take the hashed subdirectory as argument and then only
  do semething sensible if the argument is HashedPristineDir. Indeed we always
  passed it a HashedPristineDir.

patch cc6f463b406023a8274bdd7434ddc36379f2af61
Author: Ben Franksen <ben.franksen@online.de>
Date:   Sun Nov  8 14:33:04 CET 2020
  * move gethashedFiles form Darcs.Repository.HashedIO to Darcs.Util.Tree.Hashed
  
  That it belongs there is seen by noting how many imports we save.

patch b4667cca4d8db5fd4068027f4537c6620a944ed5
Author: Ben Franksen <ben.franksen@online.de>
Date:   Mon Nov  9 15:30:24 CET 2020
  * make hashed pristine use the cache
  
  This changes the interface exposed by Darcs.Util.Tree.Hashed. Instead of
  taking the hashed directory (FilePath) as argument, we now take a Cache
  instead and use fetchFileUsingCache and writeFileUsingCache to perform any
  IO from/to the hashed files. As a by-product, this removes hidden
  dependencies on the current working directory for access to hashed pristine
  files, since Cache locations are absolute paths (or remote URLs).
  
  This requires that we make a case distinction writeFileUsingCache, which
  should use size-prefixes hashes only for patches and inventories.
Attachments
msg22681 (view) Author: ganesh Date: 2021-03-27.22:24:56
>   * factor readRecorded into Darcs.Repository.Pristine.readPristine

OK

>   * readHashedPristineRoot: fail with oldRepoFailMsg instead of returning Nothing

OK

>   * some cleanup in D.R.Repair

OK

>   * cleanup: remove createPartialsPristineDirectoryTree

OK

>   * cleanup: inline copyPristineDirectoryTree

OK

>   * specialize cleanHashdir to cleanPristineDir

OK

>   * move gethashedFiles form Darcs.Repository.HashedIO to Darcs.Util.Tree.Hashed
>   
>   That it belongs there is seen by noting how many imports we save.

OK :-)

>   * make hashed pristine use the cache

> fsCreateHashedFile :: Cache -> BL.ByteString -> IO String

The doc comment for this needs a minor update to refer to 'Cache' rather
than 'FilePath'.

I have a general question about the functionality. Does this actually
mean that pristine wasn't being cached before and is now, or is it just
an internal refactor?

I am a bit confused about what darcs does right now. I have a
pristine.hashed folder in my global cache that has a lot of content, but
none of it seems to have been updated for a few months, which might
coincide with me updating to a recent darcs from a fairly old fork that
I was previously running.

The patch itself looks fine.
msg22686 (view) Author: bfrk Date: 2021-03-28.08:26:03
>>   * make hashed pristine use the cache
> 
>> fsCreateHashedFile :: Cache -> BL.ByteString -> IO String
> 
> The doc comment for this needs a minor update to refer to 'Cache' rather
> than 'FilePath'.

Will fix that.

> I have a general question about the functionality. Does this actually
> mean that pristine wasn't being cached before and is now, or is it just
> an internal refactor?
> 
> I am a bit confused about what darcs does right now. I have a
> pristine.hashed folder in my global cache that has a lot of content, but
> none of it seems to have been updated for a few months, which might
> coincide with me updating to a recent darcs from a fairly old fork that
> I was previously running.

The pristine.hashed cache was only ever used by D.R.HashedIO. Apart from
things related to garbage collection of pristine, the only exported
function was copyHashed and the only user of that was
D.R.Pristine.createPristineDirectoryTree.

In other words: the cache was used only when creating a fresh working
tree equal to pristine, which happens for instance when cloning a repo
(but, I think, only when the remote repo does not have up-to-date packs).
msg22691 (view) Author: bfrk Date: 2021-03-28.21:53:40
Following up on review.

1 patch for repository http://darcs.net/screened:

patch f6ee3c4aaabc60488e734ff7322da4663b32890a
Author: Ben Franksen <ben.franksen@online.de>
Date:   Mon Mar 29 00:10:42 CEST 2021
  * fix haddocks for fsCreateHashedFile
Attachments
History
Date User Action Args
2021-01-10 14:53:12bfrkcreate
2021-01-10 14:53:27bfrksetstatus: needs-screening -> needs-review
2021-03-27 22:24:57ganeshsetmessages: + msg22681
2021-03-27 22:25:12ganeshsetstatus: needs-review -> accepted-pending-tests
2021-03-27 23:55:57ganeshsetstatus: accepted-pending-tests -> accepted
2021-03-28 08:26:04bfrksetmessages: + msg22686
2021-03-28 21:53:40bfrksetfiles: + patch-preview.txt, fix-haddocks-for-fscreatehashedfile.dpatch, unnamed
messages: + msg22691