better prevention of auto repack

Looking through the git sources (documentation is unclear),
it seems commit doesn't ever trigger git-gc, mostly fetching and merging
seems to. I cannot easily override the setting in all those places, so
instead set gc.auto in git config when initializing a repository with
the assistant.

This does mean that the user cannot set gc.auto=0 and completely avoid
repacks, as the assistant does it daily. But, it only does it after there
are 100x the default number of loose objects, so this is probably not going
to be too annoying.
This commit is contained in:
Joey Hess 2013-03-03 14:07:13 -04:00
parent cd06ede772
commit 789ca15012
4 changed files with 26 additions and 10 deletions

View file

@ -82,8 +82,7 @@ commitStaged = do
Right _ -> do Right _ -> do
direct <- isDirect direct <- isDirect
let params = nomessage $ catMaybes let params = nomessage $ catMaybes
[ Just $ Param "-c", Just $ Param "gc.auto=0" [ Just $ Param "commit"
, Just $ Param "commit"
, Just $ Param "--quiet" , Just $ Param "--quiet"
{- In indirect mode, avoid running the {- In indirect mode, avoid running the
- usual git-annex pre-commit hook; - usual git-annex pre-commit hook;

View file

@ -15,6 +15,7 @@ import Assistant.DaemonStatus
import Assistant.Alert import Assistant.Alert
import qualified Git.LsFiles import qualified Git.LsFiles
import qualified Git.Command import qualified Git.Command
import qualified Git.Config
import Utility.ThreadScheduler import Utility.ThreadScheduler
import qualified Assistant.Threads.Watcher as Watcher import qualified Assistant.Threads.Watcher as Watcher
import Utility.LogFile import Utility.LogFile
@ -85,8 +86,16 @@ dailyCheck = do
liftIO $ void cleanup liftIO $ void cleanup
{- Allow git-gc to run once per day. More frequent gc is avoided {- Allow git-gc to run once per day. More frequent gc is avoided
- to avoid slowing things down. -} - by default to avoid slowing things down. Only run repacks when 100x
void $ liftIO $ Git.Command.runBool [Param "gc", Param "--auto"] g - the usual number of loose objects are present; we tend
- to have a lot of small objects and they should not be a
- significant size. -}
when (Git.Config.getMaybe "gc.auto" g == Just "0") $
liftIO $ void $ Git.Command.runBool
[ Param "-c", Param "gc.auto=670000"
, Param "gc"
, Param "--auto"
] g
return True return True
where where

View file

@ -302,9 +302,9 @@ initRepo primary_assistant_repo dir desc = inDir dir $ do
{- Initialize a git-annex repository in a directory with a description. -} {- Initialize a git-annex repository in a directory with a description. -}
unlessM isInitialized $ unlessM isInitialized $
initialize desc initialize desc
{- Initialize the master branch, so things that expect
- to have it will work, before any files are added. -}
unlessM (Git.Config.isBare <$> gitRepo) $ unlessM (Git.Config.isBare <$> gitRepo) $
{- Initialize the master branch, so things that expect
- to have it will work, before any files are added. -}
void $ inRepo $ Git.Command.runBool void $ inRepo $ Git.Command.runBool
[ Param "commit" [ Param "commit"
, Param "--quiet" , Param "--quiet"
@ -312,8 +312,15 @@ initRepo primary_assistant_repo dir desc = inDir dir $ do
, Param "-m" , Param "-m"
, Param "created repository" , Param "created repository"
] ]
when primary_assistant_repo $ {- Repositories directly managed by the assistant use direct mode.
-
- Automatic gc is disabled, as it can be slow. Insted, gc is done
- once a day.
-}
when primary_assistant_repo $ do
setDirect True setDirect True
inRepo $ Git.Command.run
[Param "config", Param "gc.auto", Param "0"]
getUUID getUUID
{- Adds a directory to the autostart file. -} {- Adds a directory to the autostart file. -}

7
debian/changelog vendored
View file

@ -9,9 +9,10 @@ git-annex (4.20130228) UNRELEASED; urgency=low
files in direct mode repositories. files in direct mode repositories.
* assistant: Fix dropping content when a file is moved to an archive * assistant: Fix dropping content when a file is moved to an archive
directory. directory.
* assistant: Prevent automatic commits from causing git-gc runs, * assistant: Set gc.auto=0 when creating repositories to prevent
as that can make things quite slow. Instead, git-gc --auto is run automatic commits from causing git-gc runs.
once a day. (This can be disabled by the usual gc.auto=0 setting.) * assistant: If gc.auto=0, run git-gc once a day, packing loose objects
very non-aggressively.
-- Joey Hess <joeyh@debian.org> Wed, 27 Feb 2013 23:20:40 -0400 -- Joey Hess <joeyh@debian.org> Wed, 27 Feb 2013 23:20:40 -0400