remove supportUnlocked check that is not worth its overhead

moveAnnex only gets to that check if the object file was not present
before. So in the case where dup files are being added repeatedly,
it will only run the first time, and so there's no significant speedup
from doing it; all it avoids is a single sqlite lookup. Since MVar
accesses do have overhead, it's better to optimise for the common case,
where unlocked files are supported.

removeAnnex is less clear cut, but I think mostly is skipped running on
keys when the object has already been dropped, so similar reasoning
applies.
This commit is contained in:
Joey Hess 2021-06-15 09:24:59 -04:00
parent 6099edbf1c
commit e147ae07f4
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 20 additions and 12 deletions

View file

@ -340,13 +340,12 @@ moveAnnex key af src = ifM (checkSecureHashes' key)
liftIO $ moveFile
(fromRawFilePath src)
(fromRawFilePath dest)
whenM (annexSupportUnlocked <$> Annex.getGitConfig) $ do
g <- Annex.gitRepo
fs <- map (`fromTopFilePath` g)
<$> Database.Keys.getAssociatedFiles key
unless (null fs) $ do
ics <- mapM (populatePointerFile (Restage True) key dest) fs
Database.Keys.storeInodeCaches' key [dest] (catMaybes ics)
g <- Annex.gitRepo
fs <- map (`fromTopFilePath` g)
<$> Database.Keys.getAssociatedFiles key
unless (null fs) $ do
ics <- mapM (populatePointerFile (Restage True) key dest) fs
Database.Keys.storeInodeCaches' key [dest] (catMaybes ics)
)
alreadyhave = liftIO $ R.removeLink src
@ -503,11 +502,10 @@ removeAnnex (ContentRemovalLock key) = withObjectLoc key $ \file ->
cleanObjectLoc key $ do
secureErase file
liftIO $ removeWhenExistsWith R.removeLink file
whenM (annexSupportUnlocked <$> Annex.getGitConfig) $ do
g <- Annex.gitRepo
mapM_ (\f -> void $ tryIO $ resetpointer $ fromTopFilePath f g)
=<< Database.Keys.getAssociatedFiles key
Database.Keys.removeInodeCaches key
g <- Annex.gitRepo
mapM_ (\f -> void $ tryIO $ resetpointer $ fromTopFilePath f g)
=<< Database.Keys.getAssociatedFiles key
Database.Keys.removeInodeCaches key
where
-- Check associated pointer file for modifications, and reset if
-- it's unmodified.

View file

@ -0,0 +1,10 @@
[[!comment format=mdwn
username="joey"
subject="""comment 33"""
date="2021-06-15T13:01:04Z"
content="""
Oh, there's a much better solution: If the annex object file already exists
when ingesting a new file, skip populating other associated files. They
will have already been populated. moveAnnex has to check if the annex object
file already exists anyway, so this will have zero overhead.
"""]]