assistant: On Linux, the expensive transfer scan is run niced.
This is a compromise. I would like to nice every thread except for the webapp thread, but it's not practical to do so. That would need every thread to run as a bound thread, which could add significant overhead. And any forkIO would escape the nice level.
This commit is contained in:
parent
bfd3bba093
commit
6e309b63f8
4 changed files with 46 additions and 1 deletions
|
@ -24,6 +24,7 @@ import qualified Remote
|
||||||
import qualified Types.Remote as Remote
|
import qualified Types.Remote as Remote
|
||||||
import Utility.ThreadScheduler
|
import Utility.ThreadScheduler
|
||||||
import Utility.NotificationBroadcaster
|
import Utility.NotificationBroadcaster
|
||||||
|
import Utility.Batch
|
||||||
import qualified Git.LsFiles as LsFiles
|
import qualified Git.LsFiles as LsFiles
|
||||||
import qualified Backend
|
import qualified Backend
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
|
@ -114,7 +115,7 @@ failedTransferScan r = do
|
||||||
- since we need to look at the locations of all keys anyway.
|
- since we need to look at the locations of all keys anyway.
|
||||||
-}
|
-}
|
||||||
expensiveScan :: UrlRenderer -> [Remote] -> Assistant ()
|
expensiveScan :: UrlRenderer -> [Remote] -> Assistant ()
|
||||||
expensiveScan urlrenderer rs = unless onlyweb $ do
|
expensiveScan urlrenderer rs = unless onlyweb $ batch <~> do
|
||||||
debug ["starting scan of", show visiblers]
|
debug ["starting scan of", show visiblers]
|
||||||
|
|
||||||
unwantedrs <- liftAnnex $ S.fromList
|
unwantedrs <- liftAnnex $ S.fromList
|
||||||
|
|
40
Utility/Batch.hs
Normal file
40
Utility/Batch.hs
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
{- Running a long or expensive batch operation niced.
|
||||||
|
-
|
||||||
|
- Copyright 2013 Joey Hess <joey@kitenet.net>
|
||||||
|
-
|
||||||
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
|
module Utility.Batch where
|
||||||
|
|
||||||
|
#if defined(__LINUX__) || defined(__ANDROID__)
|
||||||
|
import Control.Concurrent.Async
|
||||||
|
import System.Posix.Process
|
||||||
|
#endif
|
||||||
|
|
||||||
|
{- Runs an operation, at batch priority.
|
||||||
|
-
|
||||||
|
- This is done by running it in a bound thread, which on Linux can be set
|
||||||
|
- to have a different nice level than the rest of the program. Note that
|
||||||
|
- due to running in a bound thread, some operations may be more expensive
|
||||||
|
- to perform. Also note that if the action calls forkIO or forkOS itself,
|
||||||
|
- that will make a new thread that does not have the batch priority.
|
||||||
|
-
|
||||||
|
- POSIX threads do not support separate nice levels, so on other operating
|
||||||
|
- systems, the action is simply ran.
|
||||||
|
-}
|
||||||
|
batch :: IO a -> IO a
|
||||||
|
#if defined(__LINUX__) || defined(__ANDROID__)
|
||||||
|
batch a = wait =<< batchthread
|
||||||
|
where
|
||||||
|
batchthread = asyncBound $ do
|
||||||
|
setProcessPriority 0 maxNice
|
||||||
|
a
|
||||||
|
#else
|
||||||
|
batch a = a
|
||||||
|
#endif
|
||||||
|
|
||||||
|
maxNice :: Int
|
||||||
|
maxNice = 19
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -35,6 +35,7 @@ git-annex (4.20130602) UNRELEASED; urgency=low
|
||||||
git-annex branch.
|
git-annex branch.
|
||||||
* Windows: The test suite now passes on Windows (a few broken parts are
|
* Windows: The test suite now passes on Windows (a few broken parts are
|
||||||
disabled).
|
disabled).
|
||||||
|
* assistant: On Linux, the expensive transfer scan is run niced.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Mon, 10 Jun 2013 12:52:44 -0400
|
-- Joey Hess <joeyh@debian.org> Mon, 10 Jun 2013 12:52:44 -0400
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,9 @@ Executable git-annex
|
||||||
Build-Depends: data-endian
|
Build-Depends: data-endian
|
||||||
CPP-Options: -D__ANDROID__
|
CPP-Options: -D__ANDROID__
|
||||||
|
|
||||||
|
if os(linux)
|
||||||
|
CPP-Options: -D__LINUX__
|
||||||
|
|
||||||
if os(linux) && flag(Inotify)
|
if os(linux) && flag(Inotify)
|
||||||
Build-Depends: hinotify
|
Build-Depends: hinotify
|
||||||
CPP-Options: -DWITH_INOTIFY
|
CPP-Options: -DWITH_INOTIFY
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue