Skip to content

Preserve dirty set and add dirtiness assertion #2279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ghcide/ghcide.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,12 @@ library
Development.IDE.Types.Action
Text.Fuzzy.Parallel

ghc-options: -Wall -Wno-name-shadowing -Wincomplete-uni-patterns -Wno-unticked-promoted-constructors
ghc-options:
-Wall
-Wno-name-shadowing
-Wincomplete-uni-patterns
-Wno-unticked-promoted-constructors
-fno-ignore-asserts

if flag(ghc-patched-unboxed-bytecode)
cpp-options: -DGHC_PATCHED_UNBOXED_BYTECODE
Expand Down
12 changes: 8 additions & 4 deletions ghcide/src/Development/IDE/Core/Shake.hs
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,12 @@ import Development.IDE.Core.PositionMapping
import Development.IDE.Core.ProgressReporting
import Development.IDE.Core.RuleTypes
import Development.IDE.Core.Tracing
import Development.IDE.GHC.Compat (NameCacheUpdater (..),
upNameCache, NameCache,
import Development.IDE.GHC.Compat (NameCache,
NameCacheUpdater (..),
initNameCache,
knownKeyNames,
mkSplitUniqSupply,
knownKeyNames)
upNameCache)
import Development.IDE.GHC.Orphans ()
import Development.IDE.Graph hiding (ShakeValue)
import qualified Development.IDE.Graph as Shake
Expand Down Expand Up @@ -914,7 +915,10 @@ defineEarlyCutoff' doDiagnostics key file old mode action = do
updateFileDiagnostics file (Key key) extras $ map (\(_,y,z) -> (y,z)) $ Vector.toList diags
return $ Just $ RunResult ChangedNothing old $ A v
_ -> return Nothing
_ -> return Nothing
_ ->
-- assert that a "clean" rule is never a cache miss
-- as this is likely a bug in the dirty key tracking
assert (mode /= RunDependenciesSame) $ return Nothing
res <- case val of
Just res -> return res
Nothing -> do
Expand Down
2 changes: 1 addition & 1 deletion hls-graph/src/Development/IDE/Graph/Internal/Database.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ incDatabase db (Just kk) = do
intern <- readIORef (databaseIds db)
let dirtyIds = mapMaybe (`Intern.lookup` intern) kk
transitiveDirtyIds <- transitiveDirtySet db dirtyIds
writeIORef (databaseDirtySet db) (Just $ Set.toList transitiveDirtyIds)
modifyIORef (databaseDirtySet db) (\dd -> Just $ fromMaybe mempty dd <> transitiveDirtyIds)
withLock (databaseLock db) $
Ids.forMutate (databaseValues db) $ \i -> \case
(k, Running _ _ x) -> (k, Dirty x)
Expand Down
3 changes: 2 additions & 1 deletion hls-graph/src/Development/IDE/Graph/Internal/Profile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import qualified Data.HashMap.Strict as Map
import Data.IORef
import Data.IntMap (IntMap)
import qualified Data.IntMap as IntMap
import qualified Data.IntSet as Set
import Data.List (dropWhileEnd, foldl',
intercalate, partition,
sort, sortBy)
Expand Down Expand Up @@ -45,7 +46,7 @@ writeProfile :: FilePath -> Database -> IO ()
writeProfile out db = do
dirtyKeys <- readIORef (databaseDirtySet db)
(report, mapping) <- toReport db
let dirtyKeysMapped = mapMaybe (`IntMap.lookup` mapping) <$> dirtyKeys
let dirtyKeysMapped = mapMaybe (`IntMap.lookup` mapping) . Set.toList <$> dirtyKeys
rpt <- generateHTML (sort <$> dirtyKeysMapped) report
LBS.writeFile out rpt

Expand Down
3 changes: 2 additions & 1 deletion hls-graph/src/Development/IDE/Graph/Internal/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ data Database = Database {
databaseExtra :: Dynamic,
databaseRules :: TheRules,
databaseStep :: !(IORef Step),
databaseDirtySet :: IORef (Maybe [Id]),
-- | Nothing means that everything is dirty
databaseDirtySet :: IORef (Maybe IntSet),
-- Hold the lock while mutating Ids/Values
databaseLock :: !Lock,
databaseIds :: !(IORef (Intern Key)),
Expand Down