diff options
author | Alexander Foremny <aforemny@posteo.de> | 2023-11-07 22:12:00 +0100 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2023-11-07 22:12:02 +0100 |
commit | 83e40ef27b2291ff7308243cbecf9431f3489554 (patch) | |
tree | 0efddedf9767be23cb3ad4500372d7b0539e916d /app/History | |
parent | 60fb967e2de7ab290f46d4a84fd920dfe8d264b0 (diff) |
fix performance when generating history
At some point, we noticed a performance drop when generating the
history. It turns out that per-file granularity is not performant
anymore, presumably since we're analizing changed files.
This restores performance by switching to per-commit granularity
instead.
Diffstat (limited to 'app/History')
-rw-r--r-- | app/History/PartialCommitInfo.hs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/app/History/PartialCommitInfo.hs b/app/History/PartialCommitInfo.hs index 5272057..2337ef7 100644 --- a/app/History/PartialCommitInfo.hs +++ b/app/History/PartialCommitInfo.hs @@ -15,7 +15,8 @@ import GHC.Generics (Generic) import Git qualified import History.Cache (cached) import History.CommitHash (CommitHash (..)) -import Issue (Issue, getIssuesPar) +import Issue (Issue, getIssues) +import Parallel (parMapM) import Process (proc, sh) import System.Directory (getCurrentDirectory) import System.FilePath ((</>)) @@ -41,7 +42,7 @@ getPartialCommitInfos = do -- -- @difficulty easy commitHashes <- reverse <$> Git.getCommitHashes - mapM getCommitInfoOf (map Commit commitHashes ++ [WorkingTree]) + parMapM getCommitInfoOf (map Commit commitHashes ++ [WorkingTree]) getCommitInfoOf :: CommitHash -> IO PartialCommitInfo getCommitInfoOf WorkingTree = do @@ -69,7 +70,7 @@ getIssuesAndFilesCommitChanged hash = do let cwd = tmp </> T.unpack hash Git.withWorkingTree cwd hash do files <- gitShowChanged cwd - issues <- concat <$> catch (getIssuesPar cwd files) dieOfInvalidTreeGrepperResult + issues <- concat <$> catch (mapM (getIssues cwd) files) dieOfInvalidTreeGrepperResult pure (issues, files) dieOfInvalidTreeGrepperResult :: E.InvalidTreeGrepperResult -> IO a @@ -83,7 +84,7 @@ getIssuesAndFilesWorkingTreeChanged :: [FilePath] -> IO ([Issue], [FilePath]) getIssuesAndFilesWorkingTreeChanged paths = do cwd <- getCurrentDirectory files <- gitLsFilesModifiedIn cwd paths - issues <- concat <$> catch (getIssuesPar cwd files) dieOfInvalidTreeGrepperResult + issues <- concat <$> catch (mapM (getIssues cwd) files) dieOfInvalidTreeGrepperResult pure (issues, files) gitShowChanged :: FilePath -> IO [FilePath] |