Skip to content

Lock-less hls-graph #2411

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 8 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 0 additions & 1 deletion ghcide/.hlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
- {name: GeneralizedNewtypeDeriving, within: []}
- {name: LambdaCase, within: []}
- {name: NamedFieldPuns, within: []}
- {name: PackageImports, within: []}
- {name: RecordWildCards, within: []}
- {name: ScopedTypeVariables, within: []}
- {name: StandaloneDeriving, within: []}
Expand Down
3 changes: 3 additions & 0 deletions ghcide/src/Development/IDE/Plugin/Completions/Logic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,9 @@ uniqueCompl candidate unique =
importedFrom (provenance -> ImportedFrom m) = m
importedFrom (provenance -> DefinedIn m) = m
importedFrom (provenance -> Local _) = "local"
#if __GLASGOW_HASKELL__ < 810
importedFrom _ = ""
#endif

-- ---------------------------------------------------------------------
-- helper functions for infix backticks
Expand Down
6 changes: 4 additions & 2 deletions hls-graph/hls-graph.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ library
Development.IDE.Graph.Internal.Options
Development.IDE.Graph.Internal.Rules
Development.IDE.Graph.Internal.Database
Development.IDE.Graph.Internal.Ids
Development.IDE.Graph.Internal.Intern
Development.IDE.Graph.Internal.Paths
Development.IDE.Graph.Internal.Profile
Development.IDE.Graph.Internal.Types
Expand All @@ -63,11 +61,15 @@ library
, exceptions
, extra
, filepath
, focus
, hashable
, js-dgtable
, js-flot
, js-jquery
, list-t
, primitive
, stm
, stm-containers
, time
, transformers
, unordered-containers
Expand Down
14 changes: 7 additions & 7 deletions hls-graph/src/Development/IDE/Graph/Database.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ module Development.IDE.Graph.Database(
shakeGetDirtySet,
shakeGetCleanKeys
,shakeGetBuildEdges) where
import Control.Concurrent.STM (atomically,
readTVarIO)
import Data.Dynamic
import Data.IORef (readIORef)
import Data.Maybe
import Development.IDE.Graph.Classes ()
import Development.IDE.Graph.Internal.Action
import Development.IDE.Graph.Internal.Database
import qualified Development.IDE.Graph.Internal.Ids as Ids
import Development.IDE.Graph.Internal.Options
import Development.IDE.Graph.Internal.Profile (writeProfile)
import Development.IDE.Graph.Internal.Rules
Expand All @@ -45,12 +45,12 @@ shakeRunDatabase = shakeRunDatabaseForKeys Nothing
-- | Returns the set of dirty keys annotated with their age (in # of builds)
shakeGetDirtySet :: ShakeDatabase -> IO [(Key, Int)]
shakeGetDirtySet (ShakeDatabase _ _ db) =
fmap snd <$> Development.IDE.Graph.Internal.Database.getDirtySet db
Development.IDE.Graph.Internal.Database.getDirtySet db

-- | Returns the build number
shakeGetBuildStep :: ShakeDatabase -> IO Int
shakeGetBuildStep (ShakeDatabase _ _ db) = do
Step s <- readIORef $ databaseStep db
Step s <- readTVarIO $ databaseStep db
return s

-- Only valid if we never pull on the results, which we don't
Expand All @@ -64,7 +64,7 @@ shakeRunDatabaseForKeys
-> [Action a]
-> IO ([a], [IO ()])
shakeRunDatabaseForKeys keysChanged (ShakeDatabase lenAs1 as1 db) as2 = do
incDatabase db keysChanged
atomically $ incDatabase db keysChanged
as <- fmap (drop lenAs1) $ runActions db $ map unvoid as1 ++ as2
return (as, [])

Expand All @@ -75,12 +75,12 @@ shakeProfileDatabase (ShakeDatabase _ _ s) file = writeProfile file s
-- | Returns the clean keys in the database
shakeGetCleanKeys :: ShakeDatabase -> IO [(Key, Result )]
shakeGetCleanKeys (ShakeDatabase _ _ db) = do
keys <- Ids.elems $ databaseValues db
keys <- getDatabaseValues db
return [ (k,res) | (k, Clean res) <- keys]

-- | Returns the total count of edges in the build graph
shakeGetBuildEdges :: ShakeDatabase -> IO Int
shakeGetBuildEdges (ShakeDatabase _ _ db) = do
keys <- Ids.elems $ databaseValues db
keys <- getDatabaseValues db
let ress = mapMaybe (getResult . snd) keys
return $ sum $ map (length . getResultDepsDefault [] . resultDeps) ress
2 changes: 1 addition & 1 deletion hls-graph/src/Development/IDE/Graph/Internal/Action.hs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ runActions db xs = do
getDirtySet :: Action [(Key, Int)]
getDirtySet = do
db <- getDatabase
liftIO $ fmap snd <$> Development.IDE.Graph.Internal.Database.getDirtySet db
liftIO $ Development.IDE.Graph.Internal.Database.getDirtySet db

getKeysAndVisitedAge :: Action [(Key, Int)]
getKeysAndVisitedAge = do
Expand Down
Loading