Parallelize search

Why?
====

Searching hundreds or thousands of tokens with ag can be slow; this
introduces parallel processing of search so results are returned more
quickly.
This commit is contained in:
Joshua Clayton 2016-05-13 14:46:23 -04:00
parent bbb178f7d5
commit a8a9d250e3
2 changed files with 3 additions and 1 deletions

View File

@ -5,6 +5,7 @@ module Unused.CLI.ProgressIndicator
, progressWithIndicator , progressWithIndicator
) where ) where
import Control.Concurrent.ParallelIO
import Unused.CLI.Util import Unused.CLI.Util
import Unused.CLI.ProgressIndicator.Types import Unused.CLI.ProgressIndicator.Types
import Unused.CLI.ProgressIndicator.Internal import Unused.CLI.ProgressIndicator.Internal
@ -23,6 +24,6 @@ progressWithIndicator :: (a -> IO [b]) -> ProgressIndicator -> [a] -> IO [b]
progressWithIndicator f i terms = do progressWithIndicator f i terms = do
printPrefix i printPrefix i
indicator <- start i $ length terms indicator <- start i $ length terms
concat <$> sequence (ioOps indicator) <* stop indicator concat <$> parallel (ioOps indicator) <* stop indicator <* stopGlobalPool
where where
ioOps i' = map (\t -> f t <* increment i') terms ioOps i' = map (\t -> f t <* increment i') terms

View File

@ -42,6 +42,7 @@ library
, terminal-progress-bar , terminal-progress-bar
, ansi-terminal , ansi-terminal
, unix , unix
, parallel-io
ghc-options: -Wall -Werror -O2 ghc-options: -Wall -Werror -O2
default-language: Haskell2010 default-language: Haskell2010