Skip to content

Commit

Permalink
Merge branch 'master' into wip/multi-loop-2
Browse files Browse the repository at this point in the history
  • Loading branch information
wz1000 authored Apr 22, 2024
2 parents 7b9702e + 9b0699d commit 75343ef
Show file tree
Hide file tree
Showing 52 changed files with 824 additions and 683 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ runs:
sudo chown -R $USER /usr/local/.ghcup
shell: bash

- uses: haskell-actions/setup@v2.6.3
- uses: haskell-actions/setup@v2.7.1
id: HaskEnvSetup
with:
ghc-version : ${{ inputs.ghc }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ jobs:
example: ['cabal', 'lsp-types']

steps:
- uses: haskell-actions/setup@v2.6.3
- uses: haskell-actions/setup@v2.7.1
with:
ghc-version : ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:
- if: needs.pre_job.outputs.should_skip_ghcide != 'true' && matrix.test
name: Test ghcide
# run the tests without parallelism to avoid running out of memory
run: cabal test ghcide || cabal test ghcide
run: cabal test ghcide-tests || cabal test ghcide-tests

- if: matrix.test
name: Test hls-plugin-api
Expand Down
2 changes: 0 additions & 2 deletions bench/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@ buildHls Cabal root out = actionBracket
liftIO $ writeFile projectLocal $ unlines
["package haskell-language-server"
," ghc-options: -eventlog -rtsopts"
,"package ghcide"
," flags: +ekg"
]
return projectLocalExists)
(\projectLocalExists -> do
Expand Down
29 changes: 0 additions & 29 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,3 @@ constraints:
-- We want to be able to benefit from the performance optimisations
-- in the future, thus: TODO: remove this flag.
bitvec -simd

-- This is benign and won't affect our ability to release to Hackage,
-- because we only depend on `ekg-json` when a non-default flag
-- is turned on.
-- DELETE MARKER FOR CI
-- centos7 has an old version of git which cabal doesn't
-- support. We delete these lines in gitlab ci to workaround
-- this issue, as this is not necessary to build our binaries.
source-repository-package
type:git
location: https:/pepeiborra/ekg-json
tag: 7a0af7a8fd38045fd15fb13445bdcc7085325460
-- END DELETE

if impl(ghc >= 9.1)
-- ekg packagess are old and unmaintained, but we
-- don't rely on them for the mainline build, so
-- this is okay
allow-newer:
ekg-json:base,
ekg-wai:time,
ekg-core:ghc-prim

if impl(ghc >= 9.7)
-- ekg packagess are old and unmaintained, but we
-- don't rely on them for the mainline build, so
-- this is okay
allow-newer:
ekg-core:text,
11 changes: 0 additions & 11 deletions docs/contributing/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,6 @@ See the [tutorial](./plugin-tutorial.md) on writing a plugin in HLS.

## Measuring, benchmarking and tracing

### Metrics

When ghcide is built with the `ekg` flag, HLS opens a metrics server on port 8999 exposing GC and ghcide metrics. The ghcide metrics currently exposed are:

- `ghcide.values_count` - count of build results in the store
- `ghcide.database_count` - count of build keys in the store (these two would be the same in the absence of GC)
- `ghcide.build_count` - build count. A key is GC'ed if it is dirty and older than 100 builds
- `ghcide.dirty_keys_count` - non transitive count of dirty build keys
- `ghcide.indexing_pending_count` - count of items in the indexing queue
- `ghcide.exports_map_count` - count of identifiers in the exports map.

### Benchmarks

If you are touching performance sensitive code, take the time to run a differential
Expand Down
11 changes: 3 additions & 8 deletions exe/Wrapper.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@ import qualified Data.Text as T
import qualified Data.Text.IO as T
import Development.IDE.LSP.LanguageServer (runLanguageServer)
import qualified Development.IDE.Main as Main
import GHC.Stack.Types (emptyCallStack)
import Ide.Logger (Doc, Logger (Logger),
Pretty (pretty),
Recorder (logger_),
WithPriority (WithPriority),
import Ide.Logger (Doc, Pretty (pretty),
Recorder, WithPriority,
cmapWithPrio,
makeDefaultStderrRecorder)
import Ide.Plugin.Config (Config)
Expand Down Expand Up @@ -272,9 +269,7 @@ newtype ErrorLSPM c a = ErrorLSPM { unErrorLSPM :: (LspM c) a }
-- to shut down the LSP.
launchErrorLSP :: Recorder (WithPriority (Doc ())) -> T.Text -> IO ()
launchErrorLSP recorder errorMsg = do
let logger = Logger $ \p m -> logger_ recorder (WithPriority p emptyCallStack (pretty m))

let defaultArguments = Main.defaultArguments (cmapWithPrio pretty recorder) logger (IdePlugins [])
let defaultArguments = Main.defaultArguments (cmapWithPrio pretty recorder) (IdePlugins [])

inH <- Main.argsHandleIn defaultArguments

Expand Down
9 changes: 4 additions & 5 deletions ghcide-bench/src/Experiments.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ import qualified Data.Text as T
import Data.Version
import Development.IDE.Plugin.Test
import Development.IDE.Test.Diagnostic
import Development.Shake (CmdOption (Cwd, FileStdout),
cmd_)
import Development.Shake (CmdOption (Cwd), cmd_)
import Experiments.Types
import Language.LSP.Protocol.Capabilities
import qualified Language.LSP.Protocol.Lens as L
Expand Down Expand Up @@ -128,7 +127,7 @@ experiments =
(\docs -> do
hieYamlUri <- getDocUri "hie.yaml"
liftIO $ appendFile (fromJust $ uriToFilePath hieYamlUri) "##\n"
sendNotification SMethod_WorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams $
sendNotification SMethod_WorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams
[ FileEvent hieYamlUri FileChangeType_Changed ]
flip allWithIdentifierPos docs $ \DocumentPositions{..} -> isJust <$> getHover doc (fromJust identifierP)
),
Expand Down Expand Up @@ -210,7 +209,7 @@ experiments =
( \docs -> do
hieYamlUri <- getDocUri "hie.yaml"
liftIO $ appendFile (fromJust $ uriToFilePath hieYamlUri) "##\n"
sendNotification SMethod_WorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams $
sendNotification SMethod_WorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams
[ FileEvent hieYamlUri FileChangeType_Changed ]
waitForProgressStart
waitForProgressStart
Expand Down Expand Up @@ -777,7 +776,7 @@ setupDocumentContents config =
findEndOfImports :: [DocumentSymbol] -> Maybe Position
findEndOfImports (DocumentSymbol{_kind = SymbolKind_Module, _name = "imports", _range} : _) =
Just $ Position (succ $ _line $ _end _range) 4
findEndOfImports [DocumentSymbol{_kind = SymbolKind_File, _children = Just (cc)}] =
findEndOfImports [DocumentSymbol{_kind = SymbolKind_File, _children = Just cc}] =
findEndOfImports cc
findEndOfImports (DocumentSymbol{_range} : _) =
Just $ _range ^. L.start
Expand Down
2 changes: 0 additions & 2 deletions ghcide/exe/Arguments.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ data Arguments = Arguments
,argsVerbose :: Bool
,argsCommand :: Command
,argsConservativeChangeTracking :: Bool
,argsMonitoringPort :: Int
}

getArguments :: IdePlugins IdeState -> IO Arguments
Expand All @@ -43,7 +42,6 @@ arguments plugins = Arguments
<*> switch (short 'd' <> long "verbose" <> help "Include internal events in logging output")
<*> (commandP plugins <|> lspCommand <|> checkCommand)
<*> switch (long "conservative-change-tracking" <> help "disable reactive change tracking (for testing/debugging)")
<*> option auto (long "monitoring-port" <> metavar "PORT" <> value 8999 <> showDefault <> help "Port to use for EKG monitoring (if the binary is built with EKG)")
where
checkCommand = Check <$> many (argument str (metavar "FILES/DIRS..."))
lspCommand = LSP <$ flag' True (long "lsp" <> help "Start talking to an LSP client")
22 changes: 8 additions & 14 deletions ghcide/exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@ import Development.IDE (action)
import Development.IDE.Core.OfInterest (kick)
import Development.IDE.Core.Rules (mainRule)
import qualified Development.IDE.Core.Rules as Rules
import Development.IDE.Core.Tracing (withTelemetryLogger)
import Development.IDE.Core.Tracing (withTelemetryRecorder)
import qualified Development.IDE.Main as IDEMain
import qualified Development.IDE.Monitoring.EKG as EKG
import qualified Development.IDE.Monitoring.OpenTelemetry as OpenTelemetry
import qualified Development.IDE.Plugin.HLS.GhcIde as GhcIde
import Development.IDE.Types.Options
import GHC.Stack (emptyCallStack)
import Ide.Logger (Logger (Logger),
LoggingColumn (DataColumn, PriorityColumn),
import Ide.Logger (LoggingColumn (DataColumn, PriorityColumn),
Pretty (pretty),
Priority (Debug, Error, Info),
WithPriority (WithPriority, priority),
Expand Down Expand Up @@ -72,7 +69,7 @@ ghcideVersion = do
<> gitHashSection

main :: IO ()
main = withTelemetryLogger $ \telemetryLogger -> do
main = withTelemetryRecorder $ \telemetryRecorder -> do
-- stderr recorder just for plugin cli commands
pluginCliRecorder <-
cmapWithPrio pretty
Expand Down Expand Up @@ -110,23 +107,20 @@ main = withTelemetryLogger $ \telemetryLogger -> do
(lspLogRecorder & cmapWithPrio (renderStrict . layoutPretty defaultLayoutOptions)
& cfilter (\WithPriority{ priority } -> priority >= minPriority)) <>
(lspMessageRecorder & cmapWithPrio (renderStrict . layoutPretty defaultLayoutOptions)
& cfilter (\WithPriority{ priority } -> priority >= Error))

-- exists so old-style logging works. intended to be phased out
let logger = Logger $ \p m -> Logger.logger_ docWithFilteredPriorityRecorder (WithPriority p emptyCallStack (pretty m))
& cfilter (\WithPriority{ priority } -> priority >= Error)) <>
telemetryRecorder

let recorder = docWithFilteredPriorityRecorder
& cmapWithPrio pretty

let arguments =
if argsTesting
then IDEMain.testing (cmapWithPrio LogIDEMain recorder) logger hlsPlugins
else IDEMain.defaultArguments (cmapWithPrio LogIDEMain recorder) logger hlsPlugins
then IDEMain.testing (cmapWithPrio LogIDEMain recorder) hlsPlugins
else IDEMain.defaultArguments (cmapWithPrio LogIDEMain recorder) hlsPlugins

IDEMain.defaultMain (cmapWithPrio LogIDEMain recorder) arguments
{ IDEMain.argsProjectRoot = Just argsCwd
, IDEMain.argCommand = argsCommand
, IDEMain.argsLogger = IDEMain.argsLogger arguments <> pure telemetryLogger
, IDEMain.argsHlsPlugins = IDEMain.argsHlsPlugins arguments <> pluginDescToIdePlugins [lspRecorderPlugin]

, IDEMain.argsRules = do
Expand All @@ -148,5 +142,5 @@ main = withTelemetryLogger $ \telemetryLogger -> do
, optRunSubset = not argsConservativeChangeTracking
, optVerifyCoreFile = argsVerifyCoreFile
}
, IDEMain.argsMonitoring = OpenTelemetry.monitoring <> EKG.monitoring logger argsMonitoringPort
, IDEMain.argsMonitoring = OpenTelemetry.monitoring
}
113 changes: 0 additions & 113 deletions ghcide/ghcide.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ source-repository head
type: git
location: https:/haskell/haskell-language-server.git

flag ekg
description:
Enable EKG monitoring of the build graph and other metrics on port 8999

default: False
manual: True

flag pedantic
description: Enable -Werror
default: False
Expand Down Expand Up @@ -178,7 +171,6 @@ library
Development.IDE.LSP.Server
Development.IDE.Main
Development.IDE.Main.HeapStats
Development.IDE.Monitoring.EKG
Development.IDE.Monitoring.OpenTelemetry
Development.IDE.Plugin
Development.IDE.Plugin.Completions
Expand Down Expand Up @@ -218,13 +210,6 @@ library
ghc-options:
-Werror

if flag(ekg)
build-depends:
, ekg-core
, ekg-wai

cpp-options: -DMONITORING_EKG

flag test-exe
description: Build the ghcide-test-preprocessor executable
default: True
Expand Down Expand Up @@ -312,101 +297,3 @@ library ghcide-test-utils
OverloadedStrings
RecordWildCards
ViewPatterns

test-suite ghcide-tests
import: warnings
type: exitcode-stdio-1.0
default-language: GHC2021
build-tool-depends:
, ghcide:ghcide
, ghcide:ghcide-test-preprocessor
, implicit-hie:gen-hie

build-depends:
, aeson
, async
, base
, containers
, data-default
, directory
, enummapset
, extra
, filepath
, fuzzy
, ghcide
, ghcide:ghcide-test-utils
, hls-plugin-api
, lens
, list-t
, lsp
, lsp-test ^>=0.17.0.0
, lsp-types
, monoid-subclasses
, mtl
, network-uri
, QuickCheck
, random
, regex-tdfa ^>=1.3.1
, row-types
, shake
, sqlite-simple
, stm
, stm-containers
, tasty
, tasty-expected-failure
, tasty-hunit >=0.10
, tasty-quickcheck
, tasty-rerun
, text
, text-rope
, unordered-containers

if impl(ghc <9.3)
build-depends: ghc-typelits-knownnat

hs-source-dirs: test/exe
ghc-options: -threaded -O0

main-is: Main.hs
other-modules:
AsyncTests
BootTests
ClientSettingsTests
CodeLensTests
CompletionTests
CPPTests
CradleTests
DependentFileTest
DiagnosticTests
ExceptionTests
FindDefinitionAndHoverTests
FuzzySearch
GarbageCollectionTests
HaddockTests
HieDbRetry
HighlightTests
IfaceTests
InitializeResponseTests
LogType
NonLspCommandLine
OpenCloseTest
OutlineTests
PluginSimpleTests
PositionMappingTests
PreprocessorTests
Progress
ReferenceTests
RootUriTests
SafeTests
SymlinkTests
TestUtils
THTests
UnitTests
WatchedFileTests

-- Tests that have been pulled out of the main file
default-extensions:
LambdaCase
OverloadedStrings
RecordWildCards
ViewPatterns
11 changes: 6 additions & 5 deletions ghcide/src/Development/IDE/Core/OfInterest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ import Development.IDE.Types.Location
import Development.IDE.Types.Options (IdeTesting (..))
import GHC.TypeLits (KnownSymbol)
import Ide.Logger (Pretty (pretty),
Priority (..),
Recorder,
WithPriority,
cmapWithPrio,
logDebug)
logWith)
import qualified Language.LSP.Protocol.Message as LSP
import qualified Language.LSP.Server as LSP

Expand Down Expand Up @@ -110,16 +111,16 @@ addFileOfInterest state f v = do
pure (new, (prev, new))
when (prev /= Just v) $ do
join $ atomically $ recordDirtyKeys (shakeExtras state) IsFileOfInterest [f]
logDebug (ideLogger state) $
"Set files of interest to: " <> T.pack (show files)
logWith (ideLogger state) Debug $
LogSetFilesOfInterest (HashMap.toList files)

deleteFileOfInterest :: IdeState -> NormalizedFilePath -> IO ()
deleteFileOfInterest state f = do
OfInterestVar var <- getIdeGlobalState state
files <- modifyVar' var $ HashMap.delete f
join $ atomically $ recordDirtyKeys (shakeExtras state) IsFileOfInterest [f]
logDebug (ideLogger state) $ "Set files of interest to: " <> T.pack (show files)

logWith (ideLogger state) Debug $
LogSetFilesOfInterest (HashMap.toList files)
scheduleGarbageCollection :: IdeState -> IO ()
scheduleGarbageCollection state = do
GarbageCollectVar var <- getIdeGlobalState state
Expand Down
Loading

0 comments on commit 75343ef

Please sign in to comment.