smarter BranchState cache invalidation
Only invalidate a just-written file in the cache, not the whole cache.
This will avoid the possibly performance impact of cache invalidation
mentioned in commit 770aac97a7
This commit is contained in:
parent
770aac97a7
commit
bd3d327d8a
2 changed files with 11 additions and 5 deletions
|
@ -262,7 +262,7 @@ updateTo' pairs = do
|
||||||
else commitIndex jl branchref merge_desc commitrefs
|
else commitIndex jl branchref merge_desc commitrefs
|
||||||
)
|
)
|
||||||
addMergedRefs tomerge
|
addMergedRefs tomerge
|
||||||
invalidateCache
|
invalidateCacheAll
|
||||||
|
|
||||||
stagejournalwhen dirty jl a
|
stagejournalwhen dirty jl a
|
||||||
| dirty = stageJournal jl a
|
| dirty = stageJournal jl a
|
||||||
|
@ -487,7 +487,7 @@ set jl ru f c = do
|
||||||
-- evaluating a Journalable Builder twice, which is not very
|
-- evaluating a Journalable Builder twice, which is not very
|
||||||
-- efficient. Instead, assume that it's not common to need to read
|
-- efficient. Instead, assume that it's not common to need to read
|
||||||
-- a log file immediately after writing it.
|
-- a log file immediately after writing it.
|
||||||
invalidateCache
|
invalidateCache f
|
||||||
|
|
||||||
{- Appends content to the journal file. -}
|
{- Appends content to the journal file. -}
|
||||||
append :: Journalable content => JournalLocked -> RawFilePath -> AppendableJournalFile -> content -> Annex ()
|
append :: Journalable content => JournalLocked -> RawFilePath -> AppendableJournalFile -> content -> Annex ()
|
||||||
|
@ -495,7 +495,7 @@ append jl f appendable toappend = do
|
||||||
journalChanged
|
journalChanged
|
||||||
appendJournalFile jl appendable toappend
|
appendJournalFile jl appendable toappend
|
||||||
fastDebug "Annex.Branch" ("append " ++ fromRawFilePath f)
|
fastDebug "Annex.Branch" ("append " ++ fromRawFilePath f)
|
||||||
invalidateCache
|
invalidateCache f
|
||||||
|
|
||||||
{- Commit message used when making a commit of whatever data has changed
|
{- Commit message used when making a commit of whatever data has changed
|
||||||
- to the git-annex branch. -}
|
- to the git-annex branch. -}
|
||||||
|
|
|
@ -134,5 +134,11 @@ getCache file state = go (cachedFileContents state)
|
||||||
| f == file && not (needInteractiveAccess state) = Just c
|
| f == file && not (needInteractiveAccess state) = Just c
|
||||||
| otherwise = go rest
|
| otherwise = go rest
|
||||||
|
|
||||||
invalidateCache :: Annex ()
|
invalidateCache :: RawFilePath -> Annex ()
|
||||||
invalidateCache = changeState $ \s -> s { cachedFileContents = [] }
|
invalidateCache f = changeState $ \s -> s
|
||||||
|
{ cachedFileContents = filter (\(f', _) -> f' /= f)
|
||||||
|
(cachedFileContents s)
|
||||||
|
}
|
||||||
|
|
||||||
|
invalidateCacheAll :: Annex ()
|
||||||
|
invalidateCacheAll = changeState $ \s -> s { cachedFileContents = [] }
|
||||||
|
|
Loading…
Reference in a new issue