unannex, uninit: Avoid running git rm once per annexed file, for a large speedup.
authorJoey Hess <joeyh@joeyh.name>
Mon, 22 Feb 2021 16:56:11 +0000 (12:56 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 22 Feb 2021 16:56:11 +0000 (12:56 -0400)
CHANGELOG
Command/Unannex.hs
doc/todo/optimization_needed__58___slow_uninit.mdwn
doc/todo/optimization_needed__58___slow_uninit/comment_1_3d01d125ffea8dd247e68f716a9c636a._comment [new file with mode: 0644]

index 794bc5d71bbd34e5fce81c180f4db7f31d1f14bb..cd27e8a44d9bfba2d05812ccc0934cf8e8cc402b 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -28,6 +28,8 @@ git-annex (8.20210128) UNRELEASED; urgency=medium
     rather than doing it in a second pass.
   * Bugfix: fsck --from a ssh remote did not actually check that the
     content on the remote is not corrupted.
+  * unannex, uninit: Avoid running git rm once per annexed file,
+    for a large speedup.
 
  -- Joey Hess <id@joeyh.name>  Thu, 28 Jan 2021 12:34:32 -0400
 
index 0b383dd9b12e6df07aa2706b6e71bfef8bda7bfa..690a946be617256151f512eb515e0c8726c7de0a 100644 (file)
@@ -1,6 +1,6 @@
 {- git-annex command
  -
- - Copyright 2010-2013 Joey Hess <id@joeyh.name>
+ - Copyright 2010-2021 Joey Hess <id@joeyh.name>
  -
  - Licensed under the GNU AGPL version 3 or higher.
  -}
@@ -10,7 +10,7 @@ module Command.Unannex where
 import Command
 import qualified Annex
 import Annex.Perms
-import qualified Git.Command
+import qualified Annex.Queue
 import Utility.CopyFile
 import qualified Database.Keys
 import Git.FilePath
@@ -42,14 +42,13 @@ start si file key =
 perform :: RawFilePath -> Key -> CommandPerform
 perform file key = do
        liftIO $ removeFile (fromRawFilePath file)
-       inRepo $ Git.Command.run
-               [ Param "rm"
-               , Param "--cached"
+       Annex.Queue.addCommand [] "rm"
+               [ Param "--cached"
                , Param "--force"
                , Param "--quiet"
                , Param "--"
-               , File (fromRawFilePath file)
                ]
+               [fromRawFilePath file]
        next $ cleanup file key
 
 cleanup :: RawFilePath -> Key -> CommandCleanup
index 0b7e2d8e37264a68f022b743b4a6c3c33fb8d006..aeae0cbf1b3f8ce7d923104933383afecf324d40 100644 (file)
@@ -20,3 +20,5 @@ git annex 8.20210127-g42239bc
 
 [[!meta author=yoh]]
 [[!tag projects/datalad]]
+
+> [[fixed|done]] --[[Joey]]
diff --git a/doc/todo/optimization_needed__58___slow_uninit/comment_1_3d01d125ffea8dd247e68f716a9c636a._comment b/doc/todo/optimization_needed__58___slow_uninit/comment_1_3d01d125ffea8dd247e68f716a9c636a._comment
new file mode 100644 (file)
index 0000000..3c81325
--- /dev/null
@@ -0,0 +1,12 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 1"""
+ date="2021-02-22T16:45:46Z"
+ content="""
+Also unannex is slow the same way. Looks like it can easily be fixed using
+git command queueing; I see no reason the rm needs to happen before
+changes to the working tree, as --cached makes the rm only operate on the
+index.
+
+Rest seem fast enough.
+"""]]