git-annex/CmdLine/GitAnnex.hs

250 lines
6.6 KiB
Haskell
Raw Normal View History

{- git-annex main program
-
- Copyright 2010-2015 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
{-# LANGUAGE CPP, OverloadedStrings #-}
2014-01-26 20:25:55 +00:00
module CmdLine.GitAnnex where
import qualified Git.CurrentRepo
2011-01-07 06:15:10 +00:00
import CmdLine
import Command
import Utility.Env
import Annex.Ssh
import Annex.Multicast
import Types.Test
2015-07-10 20:32:33 +00:00
import qualified Command.Help
import qualified Command.Add
import qualified Command.Unannex
import qualified Command.Drop
import qualified Command.Move
import qualified Command.Copy
import qualified Command.Get
import qualified Command.Fsck
import qualified Command.LookupKey
import qualified Command.CalcKey
import qualified Command.ContentLocation
import qualified Command.ExamineKey
import qualified Command.MatchExpression
import qualified Command.FromKey
import qualified Command.RegisterUrl
import qualified Command.SetKey
import qualified Command.DropKey
import qualified Command.TransferKey
import qualified Command.TransferKeys
import qualified Command.SetPresentKey
import qualified Command.ReadPresentKey
import qualified Command.CheckPresentKey
import qualified Command.ReKey
import qualified Command.Adjust
import qualified Command.MetaData
import qualified Command.View
2014-02-19 00:01:56 +00:00
import qualified Command.VAdd
import qualified Command.VFilter
import qualified Command.VPop
2014-02-19 00:16:28 +00:00
import qualified Command.VCycle
2011-10-31 19:18:41 +00:00
import qualified Command.Reinject
import qualified Command.Fix
import qualified Command.Init
2011-03-03 21:21:00 +00:00
import qualified Command.Describe
2011-03-29 03:22:31 +00:00
import qualified Command.InitRemote
import qualified Command.EnableRemote
import qualified Command.EnableTor
import qualified Command.Multicast
2015-07-10 20:26:23 +00:00
import qualified Command.Expire
2013-10-23 16:21:59 +00:00
import qualified Command.Repair
import qualified Command.Unused
2015-07-10 20:15:31 +00:00
import qualified Command.DropUnused
import qualified Command.AddUnused
import qualified Command.Unlock
import qualified Command.Lock
import qualified Command.PreCommit
import qualified Command.PostReceive
import qualified Command.Find
2015-07-11 00:38:11 +00:00
import qualified Command.FindRef
2015-07-10 20:32:33 +00:00
import qualified Command.Whereis
2015-07-11 00:46:48 +00:00
import qualified Command.List
2015-07-13 14:44:51 +00:00
import qualified Command.Log
2011-06-22 22:46:45 +00:00
import qualified Command.Merge
import qualified Command.ResolveMerge
2015-07-11 14:41:52 +00:00
import qualified Command.Info
2015-07-11 14:42:46 +00:00
import qualified Command.Status
import qualified Command.Inprogress
import qualified Command.Migrate
import qualified Command.Uninit
import qualified Command.Reinit
import qualified Command.NumCopies
import qualified Command.Trust
import qualified Command.Untrust
import qualified Command.Semitrust
import qualified Command.Dead
import qualified Command.Group
import qualified Command.Wanted
import qualified Command.GroupWanted
import qualified Command.Required
import qualified Command.Schedule
import qualified Command.Ungroup
import qualified Command.Config
2015-07-11 00:40:30 +00:00
import qualified Command.Vicfg
import qualified Command.Sync
2015-07-11 01:05:34 +00:00
import qualified Command.Mirror
2015-07-13 14:57:49 +00:00
import qualified Command.AddUrl
2015-07-13 15:06:41 +00:00
import qualified Command.ImportFeed
import qualified Command.RmUrl
2015-07-13 15:15:21 +00:00
import qualified Command.Import
import qualified Command.Export
import qualified Command.Map
2012-12-13 19:44:56 +00:00
import qualified Command.Direct
import qualified Command.Indirect
2011-03-16 19:48:26 +00:00
import qualified Command.Upgrade
2015-07-11 04:42:32 +00:00
import qualified Command.Forget
2016-11-30 18:35:24 +00:00
import qualified Command.P2P
import qualified Command.Proxy
import qualified Command.DiffDriver
2015-12-04 17:02:56 +00:00
import qualified Command.Smudge
2015-07-11 04:42:32 +00:00
import qualified Command.Undo
import qualified Command.Version
import qualified Command.RemoteDaemon
#ifdef WITH_ASSISTANT
import qualified Command.Watch
import qualified Command.Assistant
#ifdef WITH_WEBAPP
import qualified Command.WebApp
#endif
#endif
import qualified Command.Test
2013-05-23 23:00:46 +00:00
import qualified Command.FuzzTest
2015-07-11 04:42:32 +00:00
import qualified Command.TestRemote
add database benchmark The benchmark shows that the database access is quite fast indeed! And, it scales linearly to the number of keys, with one exception, getAssociatedKey. Based on this benchmark, I don't think I need worry about optimising for cases where all files are locked and the database is mostly empty. In those cases, database access will be misses, and according to this benchmark, should add only 50 milliseconds to runtime. (NB: There may be some overhead to getting the database opened and locking the handle that this benchmark doesn't see.) joey@darkstar:~/src/git-annex>./git-annex benchmark setting up database with 1000 setting up database with 10000 benchmarking keys database/getAssociatedFiles from 1000 (hit) time 62.77 μs (62.70 μs .. 62.85 μs) 1.000 R² (1.000 R² .. 1.000 R²) mean 62.81 μs (62.76 μs .. 62.88 μs) std dev 201.6 ns (157.5 ns .. 259.5 ns) benchmarking keys database/getAssociatedFiles from 1000 (miss) time 50.02 μs (49.97 μs .. 50.07 μs) 1.000 R² (1.000 R² .. 1.000 R²) mean 50.09 μs (50.04 μs .. 50.17 μs) std dev 206.7 ns (133.8 ns .. 295.3 ns) benchmarking keys database/getAssociatedKey from 1000 (hit) time 211.2 μs (210.5 μs .. 212.3 μs) 1.000 R² (0.999 R² .. 1.000 R²) mean 211.0 μs (210.7 μs .. 212.0 μs) std dev 1.685 μs (334.4 ns .. 3.517 μs) benchmarking keys database/getAssociatedKey from 1000 (miss) time 173.5 μs (172.7 μs .. 174.2 μs) 1.000 R² (0.999 R² .. 1.000 R²) mean 173.7 μs (173.0 μs .. 175.5 μs) std dev 3.833 μs (1.858 μs .. 6.617 μs) variance introduced by outliers: 16% (moderately inflated) benchmarking keys database/getAssociatedFiles from 10000 (hit) time 64.01 μs (63.84 μs .. 64.18 μs) 1.000 R² (1.000 R² .. 1.000 R²) mean 64.85 μs (64.34 μs .. 66.02 μs) std dev 2.433 μs (547.6 ns .. 4.652 μs) variance introduced by outliers: 40% (moderately inflated) benchmarking keys database/getAssociatedFiles from 10000 (miss) time 50.33 μs (50.28 μs .. 50.39 μs) 1.000 R² (1.000 R² .. 1.000 R²) mean 50.32 μs (50.26 μs .. 50.38 μs) std dev 202.7 ns (167.6 ns .. 252.0 ns) benchmarking keys database/getAssociatedKey from 10000 (hit) time 1.142 ms (1.139 ms .. 1.146 ms) 1.000 R² (1.000 R² .. 1.000 R²) mean 1.142 ms (1.140 ms .. 1.144 ms) std dev 7.142 μs (4.994 μs .. 10.98 μs) benchmarking keys database/getAssociatedKey from 10000 (miss) time 1.094 ms (1.092 ms .. 1.096 ms) 1.000 R² (1.000 R² .. 1.000 R²) mean 1.095 ms (1.095 ms .. 1.097 ms) std dev 4.277 μs (2.591 μs .. 7.228 μs)
2016-01-12 17:01:44 +00:00
#ifdef WITH_BENCHMARK
import qualified Command.Benchmark
#endif
cmds :: Parser TestOptions -> Maybe TestRunner -> [Command]
cmds testoptparser testrunner =
2015-07-10 20:32:33 +00:00
[ Command.Help.cmd
, Command.Add.cmd
, Command.Get.cmd
, Command.Drop.cmd
, Command.Move.cmd
, Command.Copy.cmd
, Command.Fsck.cmd
, Command.Unlock.cmd
, Command.Unlock.editcmd
, Command.Lock.cmd
, Command.Sync.cmd
2015-07-11 01:05:34 +00:00
, Command.Mirror.cmd
2015-07-13 14:57:49 +00:00
, Command.AddUrl.cmd
2015-07-13 15:06:41 +00:00
, Command.ImportFeed.cmd
, Command.RmUrl.cmd
2015-07-13 15:15:21 +00:00
, Command.Import.cmd
, Command.Export.cmd
, Command.Init.cmd
, Command.Describe.cmd
, Command.InitRemote.cmd
, Command.EnableRemote.cmd
, Command.EnableTor.cmd
, Command.Multicast.cmd
, Command.Reinject.cmd
, Command.Unannex.cmd
, Command.Uninit.cmd
, Command.Reinit.cmd
, Command.PreCommit.cmd
, Command.PostReceive.cmd
, Command.NumCopies.cmd
, Command.Trust.cmd
, Command.Untrust.cmd
, Command.Semitrust.cmd
, Command.Dead.cmd
, Command.Group.cmd
, Command.Wanted.cmd
, Command.GroupWanted.cmd
, Command.Required.cmd
, Command.Schedule.cmd
, Command.Ungroup.cmd
, Command.Config.cmd
2015-07-11 00:40:30 +00:00
, Command.Vicfg.cmd
, Command.LookupKey.cmd
, Command.CalcKey.cmd
, Command.ContentLocation.cmd
, Command.ExamineKey.cmd
, Command.MatchExpression.cmd
, Command.FromKey.cmd
2015-03-15 18:55:44 +00:00
, Command.RegisterUrl.cmd
, Command.SetKey.cmd
, Command.DropKey.cmd
, Command.TransferKey.cmd
, Command.TransferKeys.cmd
, Command.SetPresentKey.cmd
, Command.ReadPresentKey.cmd
, Command.CheckPresentKey.cmd
, Command.ReKey.cmd
, Command.Adjust.cmd
, Command.MetaData.cmd
, Command.View.cmd
, Command.VAdd.cmd
, Command.VFilter.cmd
, Command.VPop.cmd
, Command.VCycle.cmd
, Command.Fix.cmd
2015-07-10 20:26:23 +00:00
, Command.Expire.cmd
, Command.Repair.cmd
, Command.Unused.cmd
2015-07-10 20:15:31 +00:00
, Command.DropUnused.cmd
, Command.AddUnused.cmd
, Command.Find.cmd
2015-07-11 00:38:11 +00:00
, Command.FindRef.cmd
2015-07-10 20:32:33 +00:00
, Command.Whereis.cmd
2015-07-11 00:46:48 +00:00
, Command.List.cmd
2015-07-13 14:44:51 +00:00
, Command.Log.cmd
, Command.Merge.cmd
, Command.ResolveMerge.cmd
2015-07-11 14:41:52 +00:00
, Command.Info.cmd
2015-07-11 14:42:46 +00:00
, Command.Status.cmd
, Command.Inprogress.cmd
, Command.Migrate.cmd
, Command.Map.cmd
, Command.Direct.cmd
, Command.Indirect.cmd
, Command.Upgrade.cmd
2015-07-11 04:42:32 +00:00
, Command.Forget.cmd
2016-11-30 18:35:24 +00:00
, Command.P2P.cmd
, Command.Proxy.cmd
, Command.DiffDriver.cmd
2015-12-04 17:02:56 +00:00
, Command.Smudge.cmd
2015-07-11 04:42:32 +00:00
, Command.Undo.cmd
, Command.Version.cmd
, Command.RemoteDaemon.cmd
#ifdef WITH_ASSISTANT
, Command.Watch.cmd
, Command.Assistant.cmd
#ifdef WITH_WEBAPP
, Command.WebApp.cmd
#endif
#endif
, Command.Test.cmd testoptparser testrunner
, Command.FuzzTest.cmd
2015-07-11 04:42:32 +00:00
, Command.TestRemote.cmd
add database benchmark The benchmark shows that the database access is quite fast indeed! And, it scales linearly to the number of keys, with one exception, getAssociatedKey. Based on this benchmark, I don't think I need worry about optimising for cases where all files are locked and the database is mostly empty. In those cases, database access will be misses, and according to this benchmark, should add only 50 milliseconds to runtime. (NB: There may be some overhead to getting the database opened and locking the handle that this benchmark doesn't see.) joey@darkstar:~/src/git-annex>./git-annex benchmark setting up database with 1000 setting up database with 10000 benchmarking keys database/getAssociatedFiles from 1000 (hit) time 62.77 μs (62.70 μs .. 62.85 μs) 1.000 R² (1.000 R² .. 1.000 R²) mean 62.81 μs (62.76 μs .. 62.88 μs) std dev 201.6 ns (157.5 ns .. 259.5 ns) benchmarking keys database/getAssociatedFiles from 1000 (miss) time 50.02 μs (49.97 μs .. 50.07 μs) 1.000 R² (1.000 R² .. 1.000 R²) mean 50.09 μs (50.04 μs .. 50.17 μs) std dev 206.7 ns (133.8 ns .. 295.3 ns) benchmarking keys database/getAssociatedKey from 1000 (hit) time 211.2 μs (210.5 μs .. 212.3 μs) 1.000 R² (0.999 R² .. 1.000 R²) mean 211.0 μs (210.7 μs .. 212.0 μs) std dev 1.685 μs (334.4 ns .. 3.517 μs) benchmarking keys database/getAssociatedKey from 1000 (miss) time 173.5 μs (172.7 μs .. 174.2 μs) 1.000 R² (0.999 R² .. 1.000 R²) mean 173.7 μs (173.0 μs .. 175.5 μs) std dev 3.833 μs (1.858 μs .. 6.617 μs) variance introduced by outliers: 16% (moderately inflated) benchmarking keys database/getAssociatedFiles from 10000 (hit) time 64.01 μs (63.84 μs .. 64.18 μs) 1.000 R² (1.000 R² .. 1.000 R²) mean 64.85 μs (64.34 μs .. 66.02 μs) std dev 2.433 μs (547.6 ns .. 4.652 μs) variance introduced by outliers: 40% (moderately inflated) benchmarking keys database/getAssociatedFiles from 10000 (miss) time 50.33 μs (50.28 μs .. 50.39 μs) 1.000 R² (1.000 R² .. 1.000 R²) mean 50.32 μs (50.26 μs .. 50.38 μs) std dev 202.7 ns (167.6 ns .. 252.0 ns) benchmarking keys database/getAssociatedKey from 10000 (hit) time 1.142 ms (1.139 ms .. 1.146 ms) 1.000 R² (1.000 R² .. 1.000 R²) mean 1.142 ms (1.140 ms .. 1.144 ms) std dev 7.142 μs (4.994 μs .. 10.98 μs) benchmarking keys database/getAssociatedKey from 10000 (miss) time 1.094 ms (1.092 ms .. 1.096 ms) 1.000 R² (1.000 R² .. 1.000 R²) mean 1.095 ms (1.095 ms .. 1.097 ms) std dev 4.277 μs (2.591 μs .. 7.228 μs)
2016-01-12 17:01:44 +00:00
#ifdef WITH_BENCHMARK
, Command.Benchmark.cmd
#endif
]
run :: Parser TestOptions -> Maybe TestRunner -> [String] -> IO ()
run testoptparser testrunner args = go envmodes
where
go [] = dispatch True args
(cmds testoptparser testrunner)
gitAnnexGlobalOptions [] Git.CurrentRepo.get
"git-annex"
"manage files with git, without checking their contents in"
go ((v, a):rest) = maybe (go rest) a =<< getEnv v
envmodes =
[ (sshOptionsEnv, runSshOptions args)
, (sshAskPassEnv, runSshAskPass)
, (multicastReceiveEnv, runMulticastReceive args)
]