runshell LD_HWCAP_MASK=0 optimisation
This commit is contained in:
parent
e62817c00d
commit
88e5ebcda7
6 changed files with 68 additions and 13 deletions
|
@ -24,7 +24,7 @@ import Utility.Path
|
||||||
import Utility.FileMode
|
import Utility.FileMode
|
||||||
import Utility.CopyFile
|
import Utility.CopyFile
|
||||||
|
|
||||||
mklibs :: FilePath -> a -> IO ()
|
mklibs :: FilePath -> a -> IO Bool
|
||||||
mklibs top _installedbins = do
|
mklibs top _installedbins = do
|
||||||
fs <- dirContentsRecursive top
|
fs <- dirContentsRecursive top
|
||||||
exes <- filterM checkExe fs
|
exes <- filterM checkExe fs
|
||||||
|
@ -48,6 +48,19 @@ mklibs top _installedbins = do
|
||||||
let linker = Prelude.head linkers
|
let linker = Prelude.head linkers
|
||||||
mapM_ (installLinkerShim top linker) exes
|
mapM_ (installLinkerShim top linker) exes
|
||||||
|
|
||||||
|
return (any hwcaplibdir libdirs)
|
||||||
|
where
|
||||||
|
-- hwcap lib dirs are things like foo/tls and foo/x86.
|
||||||
|
-- Hard to know if a directory is, so this is a heuristic
|
||||||
|
-- looking for things that are certianly not. If this heuristic
|
||||||
|
-- fails, a minor optimisation will not happen, but there will be
|
||||||
|
-- no bad results.
|
||||||
|
hwcaplibdir d = not $ or
|
||||||
|
[ "lib" == takeFileName d
|
||||||
|
-- eg, "lib/x86_64-linux-gnu"
|
||||||
|
, "-linux-" `isInfixOf` takeFileName d
|
||||||
|
]
|
||||||
|
|
||||||
{- If there are two libdirs that are the same except one is in
|
{- If there are two libdirs that are the same except one is in
|
||||||
- usr/lib and the other is in lib/, move the contents of the usr/lib one
|
- usr/lib and the other is in lib/, move the contents of the usr/lib one
|
||||||
- into the lib/ one. This reduces the number of directories the linker
|
- into the lib/ one. This reduces the number of directories the linker
|
||||||
|
|
|
@ -31,8 +31,10 @@ import qualified Data.Set as S
|
||||||
|
|
||||||
type LibMap = M.Map FilePath String
|
type LibMap = M.Map FilePath String
|
||||||
|
|
||||||
mklibs :: FilePath -> M.Map FilePath FilePath -> IO ()
|
mklibs :: FilePath -> M.Map FilePath FilePath -> IO Bool
|
||||||
mklibs appbase installedbins = mklibs' appbase installedbins [] [] M.empty
|
mklibs appbase installedbins = do
|
||||||
|
mklibs' appbase installedbins [] [] M.empty
|
||||||
|
return True
|
||||||
|
|
||||||
{- Recursively find and install libs, until nothing new to install is found. -}
|
{- Recursively find and install libs, until nothing new to install is found. -}
|
||||||
mklibs' :: FilePath -> M.Map FilePath FilePath -> [FilePath] -> [(FilePath, FilePath)] -> LibMap -> IO ()
|
mklibs' :: FilePath -> M.Map FilePath FilePath -> [FilePath] -> [(FilePath, FilePath)] -> LibMap -> IO ()
|
||||||
|
|
|
@ -152,13 +152,22 @@ installLocales _ = return ()
|
||||||
installLocales topdir = cp "/usr/share/i18n" (topdir </> "i18n")
|
installLocales topdir = cp "/usr/share/i18n" (topdir </> "i18n")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
installWrapper :: FilePath -> FilePath -> IO ()
|
installSkel :: FilePath -> FilePath -> IO ()
|
||||||
#ifdef darwin_HOST_OS
|
#ifdef darwin_HOST_OS
|
||||||
installWrapper topdir basedir = do
|
installSkel topdir basedir = do
|
||||||
removeDirectoryRecursive basedir
|
removeDirectoryRecursive basedir
|
||||||
createDirectoryIfMissing True (takeDirectory basedir)
|
|
||||||
unlessM (boolSystem "cp" [Param "-R", File "standalone/osx/git-annex.app", File basedir]) $
|
unlessM (boolSystem "cp" [Param "-R", File "standalone/osx/git-annex.app", File basedir]) $
|
||||||
error "cp failed"
|
error "cp failed"
|
||||||
|
#else
|
||||||
|
installSkel topdir _basedir = do
|
||||||
|
removeDirectoryRecursive topdir
|
||||||
|
unlessM (boolSystem "cp" [Param "-R", File "standalone/linux/skel", File topdir]) $
|
||||||
|
error "cp failed"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
installSkelRest :: FilePath -> FilePath -> Bool -> IO ()
|
||||||
|
#ifdef darwin_HOST_OS
|
||||||
|
installSkelRest topdir basedir _hwcaplibs = do
|
||||||
plist <- lines <$> readFile "standalone/osx/Info.plist.template"
|
plist <- lines <$> readFile "standalone/osx/Info.plist.template"
|
||||||
version <- getVersion
|
version <- getVersion
|
||||||
writeFile (basedir </> "Contents" </> "Info.plist")
|
writeFile (basedir </> "Contents" </> "Info.plist")
|
||||||
|
@ -166,11 +175,7 @@ installWrapper topdir basedir = do
|
||||||
where
|
where
|
||||||
expandversion v l = replace "GIT_ANNEX_VERSION" v l
|
expandversion v l = replace "GIT_ANNEX_VERSION" v l
|
||||||
#else
|
#else
|
||||||
installWrapper topdir _basedir = do
|
installSkelRest topdir _basedir hwcaplibs = do
|
||||||
removeDirectoryRecursive topdir
|
|
||||||
createDirectoryIfMissing True (takeDirectory topdir)
|
|
||||||
unlessM (boolSystem "cp" [Param "-R", File "standalone/linux/skel", File topdir]) $
|
|
||||||
error "cp failed"
|
|
||||||
runshell <- lines <$> readFile "standalone/linux/skel/runshell"
|
runshell <- lines <$> readFile "standalone/linux/skel/runshell"
|
||||||
-- GIT_ANNEX_PACKAGE_INSTALL can be set by a distributor and
|
-- GIT_ANNEX_PACKAGE_INSTALL can be set by a distributor and
|
||||||
-- runshell will be modified
|
-- runshell will be modified
|
||||||
|
@ -180,6 +185,12 @@ installWrapper topdir _basedir = do
|
||||||
modifyFileMode (topdir </> "runshell") (addModes executeModes)
|
modifyFileMode (topdir </> "runshell") (addModes executeModes)
|
||||||
where
|
where
|
||||||
expandrunshell (Just gapi) l@"GIT_ANNEX_PACKAGE_INSTALL=" = l ++ gapi
|
expandrunshell (Just gapi) l@"GIT_ANNEX_PACKAGE_INSTALL=" = l ++ gapi
|
||||||
|
-- This is an optimisation, that avoids the linker looking in
|
||||||
|
-- several directories for hwcap optimised libs, when there are
|
||||||
|
-- none.
|
||||||
|
expandrunshell _ l@"LD_HWCAP_MASK=" = l ++ if not hwcaplibs
|
||||||
|
then "0"
|
||||||
|
else ""
|
||||||
expandrunshell _ l = l
|
expandrunshell _ l = l
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -203,11 +214,12 @@ main :: IO ()
|
||||||
main = getArgs >>= go
|
main = getArgs >>= go
|
||||||
where
|
where
|
||||||
go (topdir:basedir:[]) = do
|
go (topdir:basedir:[]) = do
|
||||||
installWrapper topdir basedir
|
installSkel topdir basedir
|
||||||
installGitAnnex topdir
|
installGitAnnex topdir
|
||||||
installedbins <- installBundledPrograms topdir
|
installedbins <- installBundledPrograms topdir
|
||||||
installGitLibs topdir
|
installGitLibs topdir
|
||||||
installMagic topdir
|
installMagic topdir
|
||||||
installLocales topdir
|
installLocales topdir
|
||||||
mklibs topdir installedbins
|
hwcaplibs <- mklibs topdir installedbins
|
||||||
|
installSkelRest topdir basedir hwcaplibs
|
||||||
go _ = error "specify topdir and basedir"
|
go _ = error "specify topdir and basedir"
|
||||||
|
|
|
@ -61,3 +61,5 @@ git annex build: 8.20200617+git192-g5849bd634-1~ndall+1
|
||||||
|
|
||||||
[[!meta author=yoh]]
|
[[!meta author=yoh]]
|
||||||
[[!tag projects/datalad]]
|
[[!tag projects/datalad]]
|
||||||
|
|
||||||
|
> [[done]] --[[Joey]]
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
[[!comment format=mdwn
|
||||||
|
username="joey"
|
||||||
|
subject="""comment 19"""
|
||||||
|
date="2020-08-03T18:16:50Z"
|
||||||
|
content="""
|
||||||
|
Implemented the `LD_HWCAP_MASK=0` optimisation, which left only these:
|
||||||
|
|
||||||
|
strace -f ./git-annex version 2>&1 | grep ENOENT | grep openat
|
||||||
|
openat(AT_FDCWD, "/home/joey/src/git-annex/tmp/git-annex.linux//lib/x86_64-linux-gnu/tls/x86_64/libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
|
||||||
|
openat(AT_FDCWD, "/home/joey/src/git-annex/tmp/git-annex.linux//lib/x86_64-linux-gnu/tls/libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
|
||||||
|
openat(AT_FDCWD, "/home/joey/src/git-annex/tmp/git-annex.linux//lib/x86_64-linux-gnu/x86_64/libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
|
||||||
|
[pid 697752] openat(AT_FDCWD, "/home/joey/src/git-annex/tmp/git-annex.linux//lib/x86_64-linux-gnu/tls/x86_64/libpcre2-8.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
|
||||||
|
[pid 697752] openat(AT_FDCWD, "/home/joey/src/git-annex/tmp/git-annex.linux//lib/x86_64-linux-gnu/tls/libpcre2-8.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
|
||||||
|
[pid 697752] openat(AT_FDCWD, "/home/joey/src/git-annex/tmp/git-annex.linux//lib/x86_64-linux-gnu/x86_64/libpcre2-8.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
|
||||||
|
|
||||||
|
There are more failed opens now for locale files for commands like
|
||||||
|
grep when running it than there are for libraries. So, no need to
|
||||||
|
consider further prelinking.
|
||||||
|
|
||||||
|
I think that rewriting runshell in C would be the
|
||||||
|
logical next choice, but dunno if it would speed it up by enough to be
|
||||||
|
worth the effort. So I'm going to close this now.
|
||||||
|
"""]]
|
|
@ -241,6 +241,9 @@ else
|
||||||
cmd=sh
|
cmd=sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
LD_HWCAP_MASK=
|
||||||
|
export LD_HWCAP_MASK
|
||||||
|
|
||||||
if [ -n "${orig_IFS}" ]; then
|
if [ -n "${orig_IFS}" ]; then
|
||||||
IFS="${orig_IFS}"
|
IFS="${orig_IFS}"
|
||||||
export IFS
|
export IFS
|
||||||
|
|
Loading…
Reference in a new issue