git-annex/git-annex.hs
Joey Hess 067aabdd48
wip RawFilePath 2x git-annex find speedup
Finally builds (oh the agoncy of making it build), but still very
unmergable, only Command.Find is included and lots of stuff is badly
hacked to make it compile.

Benchmarking vs master, this git-annex find is significantly faster!
Specifically:

	num files	old	new	speedup
	48500		4.77	3.73	28%
	12500		1.36	1.02	66%
	20		0.075	0.074	0% (so startup time is unchanged)

That's without really finishing the optimization. Things still to do:

* Eliminate all the fromRawFilePath, toRawFilePath, encodeBS,
  decodeBS conversions.
* Use versions of IO actions like getFileStatus that take a RawFilePath.
* Eliminate some Data.ByteString.Lazy.toStrict, which is a slow copy.
* Use ByteString for parsing git config to speed up startup.

It's likely several of those will speed up git-annex find further.
And other commands will certianly benefit even more.
2019-11-26 16:01:58 -04:00

55 lines
1.4 KiB
Haskell

{- git-annex main program dispatch
-
- Copyright 2010-2016 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
{-# LANGUAGE CPP #-}
import System.Environment (getArgs, getProgName)
import System.FilePath
import Network.Socket (withSocketsDo)
import qualified CmdLine.GitAnnex
--import qualified CmdLine.GitAnnexShell
import qualified CmdLine.GitRemoteTorAnnex
import qualified Test
import qualified Benchmark
import Utility.FileSystemEncoding
#ifdef mingw32_HOST_OS
import Utility.UserInfo
import Utility.Env.Set
#endif
main :: IO ()
main = withSocketsDo $ do
useFileSystemEncoding
ps <- getArgs
#ifdef mingw32_HOST_OS
winEnv
#endif
run ps =<< getProgName
where
run ps n = case takeFileName n of
"git-annex-shell" -> error "STUBBED OUT FIXME" -- CmdLine.GitAnnexShell.run ps
"git-remote-tor-annex" -> CmdLine.GitRemoteTorAnnex.run ps
_ -> CmdLine.GitAnnex.run Test.optParser Test.runner Benchmark.mkGenerator ps
#ifdef mingw32_HOST_OS
{- On Windows, if HOME is not set, probe it and set it.
- This is a workaround for some Cygwin commands needing HOME to be set.
-
- If TZ is set, unset it.
- TZ being set can interfere with workarounds for Windows timezone
- horribleness, and prevents getCurrentTimeZone from seeing the system
- time zone.
-}
winEnv :: IO ()
winEnv = do
home <- myHomeDir
setEnv "HOME" home False
setEnv "CYGWIN" "nodosfilewarning" True
unsetEnv "TZ"
#endif