2019-08-13 19:23:03 +03:00
|
|
|
-- Copyright (c) 2019 The DAML Authors. All rights reserved.
|
2019-05-20 18:36:08 +03:00
|
|
|
-- SPDX-License-Identifier: Apache-2.0
|
2019-09-07 17:23:14 +03:00
|
|
|
{-# OPTIONS_GHC -Wno-dodgy-imports #-} -- GHC no longer exports def in GHC 8.6 and above
|
2020-01-06 11:13:14 +03:00
|
|
|
{-# LANGUAGE TemplateHaskell #-}
|
2019-05-20 18:36:08 +03:00
|
|
|
|
2019-06-26 19:07:08 +03:00
|
|
|
module Main(main) where
|
2019-05-20 18:36:08 +03:00
|
|
|
|
2019-06-26 19:07:08 +03:00
|
|
|
import Arguments
|
2019-05-20 18:36:08 +03:00
|
|
|
import Control.Concurrent.Extra
|
2019-06-26 19:07:08 +03:00
|
|
|
import Control.Monad.Extra
|
2020-09-02 20:06:04 +03:00
|
|
|
import Control.Lens ( (^.) )
|
2019-06-26 11:04:10 +03:00
|
|
|
import Data.Default
|
2020-06-02 15:44:16 +03:00
|
|
|
import Data.List.Extra
|
|
|
|
import Data.Maybe
|
|
|
|
import qualified Data.Text as T
|
|
|
|
import qualified Data.Text.IO as T
|
|
|
|
import Data.Version
|
2020-02-06 22:57:55 +03:00
|
|
|
import Development.IDE.Core.Debouncer
|
2019-06-22 11:21:59 +03:00
|
|
|
import Development.IDE.Core.FileStore
|
2019-06-25 12:09:42 +03:00
|
|
|
import Development.IDE.Core.OfInterest
|
2019-06-22 11:21:59 +03:00
|
|
|
import Development.IDE.Core.Service
|
|
|
|
import Development.IDE.Core.Rules
|
|
|
|
import Development.IDE.Core.Shake
|
|
|
|
import Development.IDE.Core.RuleTypes
|
2019-06-22 00:19:07 +03:00
|
|
|
import Development.IDE.LSP.Protocol
|
|
|
|
import Development.IDE.Types.Location
|
2019-05-20 18:36:08 +03:00
|
|
|
import Development.IDE.Types.Diagnostics
|
|
|
|
import Development.IDE.Types.Options
|
2019-06-22 11:21:59 +03:00
|
|
|
import Development.IDE.Types.Logger
|
2020-01-26 14:28:11 +03:00
|
|
|
import Development.IDE.Plugin
|
|
|
|
import Development.IDE.Plugin.Completions as Completions
|
|
|
|
import Development.IDE.Plugin.CodeAction as CodeAction
|
2020-09-07 14:29:05 +03:00
|
|
|
import Development.IDE.Plugin.Test as Test
|
2020-11-29 16:52:52 +03:00
|
|
|
import Development.IDE.Session (loadSession)
|
2020-03-16 13:31:18 +03:00
|
|
|
import qualified Language.Haskell.LSP.Core as LSP
|
2019-06-11 17:03:44 +03:00
|
|
|
import Language.Haskell.LSP.Messages
|
2020-06-02 15:44:16 +03:00
|
|
|
import Language.Haskell.LSP.Types
|
2020-09-02 20:06:04 +03:00
|
|
|
import Language.Haskell.LSP.Types.Lens (params, initializationOptions)
|
2019-06-14 12:02:04 +03:00
|
|
|
import Development.IDE.LSP.LanguageServer
|
2020-02-17 12:33:33 +03:00
|
|
|
import qualified System.Directory.Extra as IO
|
2019-05-20 18:36:08 +03:00
|
|
|
import System.Environment
|
2019-06-15 11:29:40 +03:00
|
|
|
import System.IO
|
2020-07-27 10:10:25 +03:00
|
|
|
import System.Info
|
2019-09-23 09:50:28 +03:00
|
|
|
import System.Exit
|
2020-06-02 15:44:16 +03:00
|
|
|
import System.FilePath
|
|
|
|
import System.Time.Extra
|
2019-09-23 09:50:28 +03:00
|
|
|
import Paths_ghcide
|
2020-01-06 11:13:14 +03:00
|
|
|
import Development.GitRev
|
2020-09-11 22:58:23 +03:00
|
|
|
import qualified Data.HashMap.Strict as HashMap
|
2020-09-02 20:06:04 +03:00
|
|
|
import qualified Data.Aeson as J
|
2020-06-02 15:44:16 +03:00
|
|
|
|
|
|
|
import HIE.Bios.Cradle
|
2020-11-12 22:18:21 +03:00
|
|
|
import Development.IDE (action)
|
Opentelemetry traces and heapsize memory analysis (#922)
* Move tracing functions to own module
* Bump opentelemetry to 0.6.0
* Write Values map size to OpenTelemetry metric
* Trace all requests and notifications
Instead of doing it in `HoverDefinition`, do it in
with{Response,Notification,...}. These wrap all handlers, so this should
cover everything. It also means that the span covers the entire
processing time for the request, where before we missed the setup
happening in the with* functions.
* Add flag for OpenTelemetry profiling
Run GC regularly with --ot-profiling
* Add flag to enable OT profiling in benchmark
* Use heapsize instead of ghc-datasize
I renamed the fork to distringuish from the original.
It is still being pulled from git using stack. This will be addressed
once I can push the fork to hackage.
* Bump opentelemetry to 0.6.1 - fixes 8.6 build
* Use heapsize from hackage
* Address HLint messages
* Record size of each key independently
* Refactor `startTelemetry` function
* Remove delay between measuring memory loops
* Each key in values map gets own OT instrument
* Measure values map length more rarely
* Rename --ot-profiling to --ot-memory-profiling
* Add docs for how to use the opentelemetry output
* Add instructions to build release version of tracy
* Clarify dependencies in opentelemetry instructions
* Fix LSP traces
* otTraced: delete unused
* Extract types out of D.IDE.Core.Shake
to avoid circular module dependencies
* Extract startTelemetry out of D.IDE.Shake and upgrade to 0.2
No more segfaults
* [nix] install opentelemetry
* [nix] install tracy
* Fix merge wibble
* Measure recursive sizes with sharing
* Sort keys for cost attribution
* Remove debug traces
* Allocate less, group keys, clean up hlints
* Add -A4G to the flags used for --ot-memory-profiling
* Modularize D.IDE.Core.Tracing
I want to reuse this code more directly in the non lsp driver
* Direct driver: report closure sizes when --ot-memory-profiling
An eventlog memory analysis doesnt' seem so relevant since this mode is not
interactive, but we could easily produce both if wanted to
* Everything is reachable from GhcSessionIO, so compute it last
I suspect the ShakeExtras record is reachable from GhcSessionIO
* bound recursion and use logger
* hlint suggestions
* Fix 8.6 build
* Format imports
* Do the memory analysis with full sharing. GhcSessionIO last
* Fail fast in the memory analysis
* error handling
* runHeapsize now takes initSize as an input argument
* Trace Shake sessions
* Reduced frequency for sampling values length
* Drop the -fexternal-interpreter flag in the Windows stack build
* Produce more benchmark artifacts
* Fix stack descriptors to use heapsize-0.2 from Hackage
* Bump to heapsize-0.3.0
* Record completions snippets (#900)
* Add field for RecordSnippets to CachcedCompletion
* Initial version of local record snippets
* Supprt record snippet completion for non local declarations.
* Better integration of local completions with current implementation
* Clean up non-local completions.
* Remove commented code.
* Switch from String to Text
* Remove ununsed definition
* Treat only Records and leave other defintions as is.
* Differentiate Records from Data constructors for external declaration
* Update test to include snippet in local record completions expected list.
* Update completionTest to also compare insertText.
* Add test for record snippet completion for imported records.
* Hlint fixes
* Hlint fixes
* Hlint suggestions.
* Update type.
* Consolidate imports
* Unpack tuple with explicit names
* Idiomatic changes
* Remove unused variable
* Better variable name
* Hlint suggestions
* Handle exhaustive pattern warning
* Add _ to snippet field name suggestions
* Remove type information passed around but not used
* Update to list comprehension style
* Eliminate intermediate function
* HLint suggestions.
* Idiomatic list comprehension
Co-authored-by: Pepe Iborra <pepeiborra@me.com>
* [nix] use gitignore.nix (#920)
* Ignore import list while producing completions (#919)
* Drop any items in explicit import list
* Test if imports not included in explicit list show up in completions
* Update README.md (#924)
* Custom cradle loading (#928)
When using ghcide as a library, it may be desirable to host the hie.yaml file
in a location other than the project root, or even avoid the file system altogether
* Favor `lookupPathToId` over `pathToId` (#926)
* Favor `lookupPathToId` over `pathToId`
* Fix `typecheckParentsAction`
* Fix `needsCompilationRule`
* Return completion snippets only when client supports it (#929)
* Use the real client capabilities on completions
* Return completion snippets only when supported by the client
Restored from https://github.com/haskell/ghcide/pull/900
* Redundant import
* Fix stack windows build
Co-authored-by: Michalis Pardalos <m.pardalos@gmail.com>
Co-authored-by: Michalis Pardalos <mpardalos@gmail.com>
Co-authored-by: Guru Devanla <gdevanla@users.noreply.github.com>
Co-authored-by: Samuel Ainsworth <skainsworth@gmail.com>
2020-12-05 20:44:17 +03:00
|
|
|
import Text.Printf
|
|
|
|
import Development.IDE.Core.Tracing
|
|
|
|
import Development.IDE.Types.Shake (Key(Key))
|
2020-06-02 15:44:16 +03:00
|
|
|
|
2020-01-06 11:13:14 +03:00
|
|
|
ghcideVersion :: IO String
|
|
|
|
ghcideVersion = do
|
|
|
|
path <- getExecutablePath
|
|
|
|
let gitHashSection = case $(gitHash) of
|
|
|
|
x | x == "UNKNOWN" -> ""
|
|
|
|
x -> " (GIT hash: " <> x <> ")"
|
|
|
|
return $ "ghcide version: " <> showVersion version
|
2020-07-27 10:10:25 +03:00
|
|
|
<> " (GHC: " <> showVersion compilerVersion
|
2020-01-06 11:13:14 +03:00
|
|
|
<> ") (PATH: " <> path <> ")"
|
|
|
|
<> gitHashSection
|
2019-09-23 09:50:28 +03:00
|
|
|
|
2019-05-20 18:36:08 +03:00
|
|
|
main :: IO ()
|
|
|
|
main = do
|
2019-06-14 17:23:22 +03:00
|
|
|
-- WARNING: If you write to stdout before runLanguageServer
|
|
|
|
-- then the language server will not work
|
2019-06-26 19:07:08 +03:00
|
|
|
Arguments{..} <- getArguments
|
|
|
|
|
2020-01-06 11:13:14 +03:00
|
|
|
if argsVersion then ghcideVersion >>= putStrLn >> exitSuccess
|
|
|
|
else hPutStrLn stderr {- see WARNING above -} =<< ghcideVersion
|
2019-09-23 09:50:28 +03:00
|
|
|
|
2019-05-20 18:36:08 +03:00
|
|
|
-- lock to avoid overlapping output on stdout
|
|
|
|
lock <- newLock
|
2019-09-25 14:01:41 +03:00
|
|
|
let logger p = Logger $ \pri msg -> when (pri >= p) $ withLock lock $
|
2019-06-28 14:47:45 +03:00
|
|
|
T.putStrLn $ T.pack ("[" ++ upper (show pri) ++ "] ") <> msg
|
2019-05-20 18:36:08 +03:00
|
|
|
|
2020-02-17 12:33:33 +03:00
|
|
|
whenJust argsCwd IO.setCurrentDirectory
|
2019-06-26 19:07:08 +03:00
|
|
|
|
2020-02-17 12:33:33 +03:00
|
|
|
dir <- IO.getCurrentDirectory
|
2020-04-27 13:59:13 +03:00
|
|
|
command <- makeLspCommandId "typesignature.add"
|
2019-06-15 11:29:40 +03:00
|
|
|
|
2020-01-26 14:28:11 +03:00
|
|
|
let plugins = Completions.plugin <> CodeAction.plugin
|
2020-09-07 14:29:05 +03:00
|
|
|
<> if argsTesting then Test.plugin else mempty
|
2020-09-02 20:06:04 +03:00
|
|
|
onInitialConfiguration :: InitializeRequest -> Either T.Text LspConfig
|
|
|
|
onInitialConfiguration x = case x ^. params . initializationOptions of
|
|
|
|
Nothing -> Right defaultLspConfig
|
|
|
|
Just v -> case J.fromJSON v of
|
|
|
|
J.Error err -> Left $ T.pack err
|
|
|
|
J.Success a -> Right a
|
|
|
|
onConfigurationChange = const $ Left "Updating Not supported"
|
2020-04-27 13:59:13 +03:00
|
|
|
options = def { LSP.executeCommandCommands = Just [command]
|
2020-03-16 13:31:18 +03:00
|
|
|
, LSP.completionTriggerCharacters = Just "."
|
|
|
|
}
|
2020-01-26 12:36:48 +03:00
|
|
|
|
2019-06-26 19:07:08 +03:00
|
|
|
if argLSP then do
|
|
|
|
t <- offsetTime
|
|
|
|
hPutStrLn stderr "Starting LSP server..."
|
2020-01-26 14:11:40 +03:00
|
|
|
hPutStrLn stderr "If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!"
|
2020-09-03 03:53:06 +03:00
|
|
|
runLanguageServer options (pluginHandler plugins) onInitialConfiguration onConfigurationChange $ \getLspId event vfs caps wProg wIndefProg getConfig rootPath -> do
|
2019-06-26 19:07:08 +03:00
|
|
|
t <- t
|
|
|
|
hPutStrLn stderr $ "Started LSP server in " ++ showDuration t
|
2020-09-03 03:53:06 +03:00
|
|
|
sessionLoader <- loadSession $ fromMaybe dir rootPath
|
2020-09-02 20:06:04 +03:00
|
|
|
config <- fromMaybe defaultLspConfig <$> getConfig
|
2020-06-22 19:06:50 +03:00
|
|
|
let options = (defaultIdeOptions sessionLoader)
|
Opentelemetry traces and heapsize memory analysis (#922)
* Move tracing functions to own module
* Bump opentelemetry to 0.6.0
* Write Values map size to OpenTelemetry metric
* Trace all requests and notifications
Instead of doing it in `HoverDefinition`, do it in
with{Response,Notification,...}. These wrap all handlers, so this should
cover everything. It also means that the span covers the entire
processing time for the request, where before we missed the setup
happening in the with* functions.
* Add flag for OpenTelemetry profiling
Run GC regularly with --ot-profiling
* Add flag to enable OT profiling in benchmark
* Use heapsize instead of ghc-datasize
I renamed the fork to distringuish from the original.
It is still being pulled from git using stack. This will be addressed
once I can push the fork to hackage.
* Bump opentelemetry to 0.6.1 - fixes 8.6 build
* Use heapsize from hackage
* Address HLint messages
* Record size of each key independently
* Refactor `startTelemetry` function
* Remove delay between measuring memory loops
* Each key in values map gets own OT instrument
* Measure values map length more rarely
* Rename --ot-profiling to --ot-memory-profiling
* Add docs for how to use the opentelemetry output
* Add instructions to build release version of tracy
* Clarify dependencies in opentelemetry instructions
* Fix LSP traces
* otTraced: delete unused
* Extract types out of D.IDE.Core.Shake
to avoid circular module dependencies
* Extract startTelemetry out of D.IDE.Shake and upgrade to 0.2
No more segfaults
* [nix] install opentelemetry
* [nix] install tracy
* Fix merge wibble
* Measure recursive sizes with sharing
* Sort keys for cost attribution
* Remove debug traces
* Allocate less, group keys, clean up hlints
* Add -A4G to the flags used for --ot-memory-profiling
* Modularize D.IDE.Core.Tracing
I want to reuse this code more directly in the non lsp driver
* Direct driver: report closure sizes when --ot-memory-profiling
An eventlog memory analysis doesnt' seem so relevant since this mode is not
interactive, but we could easily produce both if wanted to
* Everything is reachable from GhcSessionIO, so compute it last
I suspect the ShakeExtras record is reachable from GhcSessionIO
* bound recursion and use logger
* hlint suggestions
* Fix 8.6 build
* Format imports
* Do the memory analysis with full sharing. GhcSessionIO last
* Fail fast in the memory analysis
* error handling
* runHeapsize now takes initSize as an input argument
* Trace Shake sessions
* Reduced frequency for sampling values length
* Drop the -fexternal-interpreter flag in the Windows stack build
* Produce more benchmark artifacts
* Fix stack descriptors to use heapsize-0.2 from Hackage
* Bump to heapsize-0.3.0
* Record completions snippets (#900)
* Add field for RecordSnippets to CachcedCompletion
* Initial version of local record snippets
* Supprt record snippet completion for non local declarations.
* Better integration of local completions with current implementation
* Clean up non-local completions.
* Remove commented code.
* Switch from String to Text
* Remove ununsed definition
* Treat only Records and leave other defintions as is.
* Differentiate Records from Data constructors for external declaration
* Update test to include snippet in local record completions expected list.
* Update completionTest to also compare insertText.
* Add test for record snippet completion for imported records.
* Hlint fixes
* Hlint fixes
* Hlint suggestions.
* Update type.
* Consolidate imports
* Unpack tuple with explicit names
* Idiomatic changes
* Remove unused variable
* Better variable name
* Hlint suggestions
* Handle exhaustive pattern warning
* Add _ to snippet field name suggestions
* Remove type information passed around but not used
* Update to list comprehension style
* Eliminate intermediate function
* HLint suggestions.
* Idiomatic list comprehension
Co-authored-by: Pepe Iborra <pepeiborra@me.com>
* [nix] use gitignore.nix (#920)
* Ignore import list while producing completions (#919)
* Drop any items in explicit import list
* Test if imports not included in explicit list show up in completions
* Update README.md (#924)
* Custom cradle loading (#928)
When using ghcide as a library, it may be desirable to host the hie.yaml file
in a location other than the project root, or even avoid the file system altogether
* Favor `lookupPathToId` over `pathToId` (#926)
* Favor `lookupPathToId` over `pathToId`
* Fix `typecheckParentsAction`
* Fix `needsCompilationRule`
* Return completion snippets only when client supports it (#929)
* Use the real client capabilities on completions
* Return completion snippets only when supported by the client
Restored from https://github.com/haskell/ghcide/pull/900
* Redundant import
* Fix stack windows build
Co-authored-by: Michalis Pardalos <m.pardalos@gmail.com>
Co-authored-by: Michalis Pardalos <mpardalos@gmail.com>
Co-authored-by: Guru Devanla <gdevanla@users.noreply.github.com>
Co-authored-by: Samuel Ainsworth <skainsworth@gmail.com>
2020-12-05 20:44:17 +03:00
|
|
|
{ optReportProgress = clientSupportsProgress caps
|
|
|
|
, optShakeProfiling = argsShakeProfiling
|
|
|
|
, optOTMemoryProfiling = IdeOTMemoryProfiling argsOTMemoryProfiling
|
|
|
|
, optTesting = IdeTesting argsTesting
|
|
|
|
, optThreads = argsThreads
|
|
|
|
, optCheckParents = checkParents config
|
|
|
|
, optCheckProject = checkProject config
|
2020-01-06 21:56:40 +03:00
|
|
|
}
|
2020-06-30 12:22:20 +03:00
|
|
|
logLevel = if argsVerbose then minBound else Info
|
2020-02-06 22:57:55 +03:00
|
|
|
debouncer <- newAsyncDebouncer
|
Fix diagnostics update bug (#959)
* Preventively switch to uninterruptible mask in withMVar'
withMVar' is used to update the shakeSession var and it's crucial that the
third argument is not interrupted.
'mask' can still be interrupted for I/O actions and, while we were careful to
ensure none was used, if it ever breaks it will lead to very hard to debug
problems.
* refactor: move to RuleTypes
* Add a TestRequest to wait for arbitrary ide actions
Closes #955
* expectCurrentDiagnostics
* Add a test suite for cancellation
* Introduce --test-no-kick to fix cancellation tests reliability
* delete unsafeClearDiagnostics (unused)
* GetModSummaryWithoutTimestamps - remove StringBuffer
Since the contents of the buffer are not tracked by the fingerprint.
* Fix diagnostics bug
Given a FOI F with non null typechecking diagnostics D, imagine the following scenario:
1. An edit notification for F is received, creating a new version
2. GetModTime is executed, producing 0 diagnostics.
2.1 updateFileDiagnostics is called
2.2 setStageDiagnostics is called
2.3 LSP.updateDiagnostics is called with a new version, resetting all the
diagnostics for F
2.4 newDiags=[] in updateFileDiagnostics, which is different from D (the last
published diagnostics), which enqueues a new publishDiagnostics [] in the
Debouncer
3. An edit notification for F is received before typechecking has a chance to
run which undoes the previous edit
4. The debouncer publishes the empty set of diagnostics after waiting 0.1s
5. GetFileContents runs and since the contents of the file haven't changed since
the last time it ran, early cutoff skips everything donwstream
Since TypeCheck is skipped, the empty set of diagnostics stays published until
another edit comes.
The goal of this change is to prevent setStageDiagnostics from losing
diagnostics from other stages. To achieve this, we recover the old diagnostics
for all stages and merge them with the new stage.
* Fix hlint
* Use Map.insert for clarity
* Fix redundant imports
* Fix "code actions after edit" experiment"
2020-12-21 09:06:51 +03:00
|
|
|
let rules = do
|
|
|
|
-- install the main and ghcide-plugin rules
|
|
|
|
mainRule
|
|
|
|
pluginRules plugins
|
|
|
|
-- install the kick action, which triggers a typecheck on every
|
|
|
|
-- Shake database restart, i.e. on every user edit.
|
|
|
|
unless argsDisableKick $
|
|
|
|
action kick
|
|
|
|
initialise caps rules
|
2020-06-30 12:22:20 +03:00
|
|
|
getLspId event wProg wIndefProg (logger logLevel) debouncer options vfs
|
2019-06-13 19:21:27 +03:00
|
|
|
else do
|
2020-03-05 17:34:24 +03:00
|
|
|
-- GHC produces messages with UTF8 in them, so make sure the terminal doesn't error
|
|
|
|
hSetEncoding stdout utf8
|
|
|
|
hSetEncoding stderr utf8
|
|
|
|
|
2019-09-25 14:01:41 +03:00
|
|
|
putStrLn $ "Ghcide setup tester in " ++ dir ++ "."
|
2020-12-13 10:56:38 +03:00
|
|
|
putStrLn "Report bugs at https://github.com/haskell/ghcide/issues"
|
2019-06-26 19:07:08 +03:00
|
|
|
|
2020-06-02 15:44:16 +03:00
|
|
|
putStrLn $ "\nStep 1/4: Finding files to test in " ++ dir
|
2020-02-04 12:15:49 +03:00
|
|
|
files <- expandFiles (argFiles ++ ["." | null argFiles])
|
|
|
|
-- LSP works with absolute file paths, so try and behave similarly
|
2020-02-17 12:33:33 +03:00
|
|
|
files <- nubOrd <$> mapM IO.canonicalizePath files
|
2019-06-26 19:07:08 +03:00
|
|
|
putStrLn $ "Found " ++ show (length files) ++ " files"
|
|
|
|
|
2020-06-02 15:44:16 +03:00
|
|
|
putStrLn "\nStep 2/4: Looking for hie.yaml files that control setup"
|
2019-09-25 14:01:41 +03:00
|
|
|
cradles <- mapM findCradle files
|
|
|
|
let ucradles = nubOrd cradles
|
|
|
|
let n = length ucradles
|
|
|
|
putStrLn $ "Found " ++ show n ++ " cradle" ++ ['s' | n /= 1]
|
2020-09-02 20:43:35 +03:00
|
|
|
when (n > 0) $ putStrLn $ " (" ++ intercalate ", " (catMaybes ucradles) ++ ")"
|
2020-06-02 15:44:16 +03:00
|
|
|
putStrLn "\nStep 3/4: Initializing the IDE"
|
2019-09-25 14:01:41 +03:00
|
|
|
vfs <- makeVFSHandle
|
2020-06-02 15:44:16 +03:00
|
|
|
debouncer <- newAsyncDebouncer
|
Opentelemetry traces and heapsize memory analysis (#922)
* Move tracing functions to own module
* Bump opentelemetry to 0.6.0
* Write Values map size to OpenTelemetry metric
* Trace all requests and notifications
Instead of doing it in `HoverDefinition`, do it in
with{Response,Notification,...}. These wrap all handlers, so this should
cover everything. It also means that the span covers the entire
processing time for the request, where before we missed the setup
happening in the with* functions.
* Add flag for OpenTelemetry profiling
Run GC regularly with --ot-profiling
* Add flag to enable OT profiling in benchmark
* Use heapsize instead of ghc-datasize
I renamed the fork to distringuish from the original.
It is still being pulled from git using stack. This will be addressed
once I can push the fork to hackage.
* Bump opentelemetry to 0.6.1 - fixes 8.6 build
* Use heapsize from hackage
* Address HLint messages
* Record size of each key independently
* Refactor `startTelemetry` function
* Remove delay between measuring memory loops
* Each key in values map gets own OT instrument
* Measure values map length more rarely
* Rename --ot-profiling to --ot-memory-profiling
* Add docs for how to use the opentelemetry output
* Add instructions to build release version of tracy
* Clarify dependencies in opentelemetry instructions
* Fix LSP traces
* otTraced: delete unused
* Extract types out of D.IDE.Core.Shake
to avoid circular module dependencies
* Extract startTelemetry out of D.IDE.Shake and upgrade to 0.2
No more segfaults
* [nix] install opentelemetry
* [nix] install tracy
* Fix merge wibble
* Measure recursive sizes with sharing
* Sort keys for cost attribution
* Remove debug traces
* Allocate less, group keys, clean up hlints
* Add -A4G to the flags used for --ot-memory-profiling
* Modularize D.IDE.Core.Tracing
I want to reuse this code more directly in the non lsp driver
* Direct driver: report closure sizes when --ot-memory-profiling
An eventlog memory analysis doesnt' seem so relevant since this mode is not
interactive, but we could easily produce both if wanted to
* Everything is reachable from GhcSessionIO, so compute it last
I suspect the ShakeExtras record is reachable from GhcSessionIO
* bound recursion and use logger
* hlint suggestions
* Fix 8.6 build
* Format imports
* Do the memory analysis with full sharing. GhcSessionIO last
* Fail fast in the memory analysis
* error handling
* runHeapsize now takes initSize as an input argument
* Trace Shake sessions
* Reduced frequency for sampling values length
* Drop the -fexternal-interpreter flag in the Windows stack build
* Produce more benchmark artifacts
* Fix stack descriptors to use heapsize-0.2 from Hackage
* Bump to heapsize-0.3.0
* Record completions snippets (#900)
* Add field for RecordSnippets to CachcedCompletion
* Initial version of local record snippets
* Supprt record snippet completion for non local declarations.
* Better integration of local completions with current implementation
* Clean up non-local completions.
* Remove commented code.
* Switch from String to Text
* Remove ununsed definition
* Treat only Records and leave other defintions as is.
* Differentiate Records from Data constructors for external declaration
* Update test to include snippet in local record completions expected list.
* Update completionTest to also compare insertText.
* Add test for record snippet completion for imported records.
* Hlint fixes
* Hlint fixes
* Hlint suggestions.
* Update type.
* Consolidate imports
* Unpack tuple with explicit names
* Idiomatic changes
* Remove unused variable
* Better variable name
* Hlint suggestions
* Handle exhaustive pattern warning
* Add _ to snippet field name suggestions
* Remove type information passed around but not used
* Update to list comprehension style
* Eliminate intermediate function
* HLint suggestions.
* Idiomatic list comprehension
Co-authored-by: Pepe Iborra <pepeiborra@me.com>
* [nix] use gitignore.nix (#920)
* Ignore import list while producing completions (#919)
* Drop any items in explicit import list
* Test if imports not included in explicit list show up in completions
* Update README.md (#924)
* Custom cradle loading (#928)
When using ghcide as a library, it may be desirable to host the hie.yaml file
in a location other than the project root, or even avoid the file system altogether
* Favor `lookupPathToId` over `pathToId` (#926)
* Favor `lookupPathToId` over `pathToId`
* Fix `typecheckParentsAction`
* Fix `needsCompilationRule`
* Return completion snippets only when client supports it (#929)
* Use the real client capabilities on completions
* Return completion snippets only when supported by the client
Restored from https://github.com/haskell/ghcide/pull/900
* Redundant import
* Fix stack windows build
Co-authored-by: Michalis Pardalos <m.pardalos@gmail.com>
Co-authored-by: Michalis Pardalos <mpardalos@gmail.com>
Co-authored-by: Guru Devanla <gdevanla@users.noreply.github.com>
Co-authored-by: Samuel Ainsworth <skainsworth@gmail.com>
2020-12-05 20:44:17 +03:00
|
|
|
let dummyWithProg _ _ f = f (const (pure ()))
|
2020-06-22 19:06:50 +03:00
|
|
|
sessionLoader <- loadSession dir
|
Opentelemetry traces and heapsize memory analysis (#922)
* Move tracing functions to own module
* Bump opentelemetry to 0.6.0
* Write Values map size to OpenTelemetry metric
* Trace all requests and notifications
Instead of doing it in `HoverDefinition`, do it in
with{Response,Notification,...}. These wrap all handlers, so this should
cover everything. It also means that the span covers the entire
processing time for the request, where before we missed the setup
happening in the with* functions.
* Add flag for OpenTelemetry profiling
Run GC regularly with --ot-profiling
* Add flag to enable OT profiling in benchmark
* Use heapsize instead of ghc-datasize
I renamed the fork to distringuish from the original.
It is still being pulled from git using stack. This will be addressed
once I can push the fork to hackage.
* Bump opentelemetry to 0.6.1 - fixes 8.6 build
* Use heapsize from hackage
* Address HLint messages
* Record size of each key independently
* Refactor `startTelemetry` function
* Remove delay between measuring memory loops
* Each key in values map gets own OT instrument
* Measure values map length more rarely
* Rename --ot-profiling to --ot-memory-profiling
* Add docs for how to use the opentelemetry output
* Add instructions to build release version of tracy
* Clarify dependencies in opentelemetry instructions
* Fix LSP traces
* otTraced: delete unused
* Extract types out of D.IDE.Core.Shake
to avoid circular module dependencies
* Extract startTelemetry out of D.IDE.Shake and upgrade to 0.2
No more segfaults
* [nix] install opentelemetry
* [nix] install tracy
* Fix merge wibble
* Measure recursive sizes with sharing
* Sort keys for cost attribution
* Remove debug traces
* Allocate less, group keys, clean up hlints
* Add -A4G to the flags used for --ot-memory-profiling
* Modularize D.IDE.Core.Tracing
I want to reuse this code more directly in the non lsp driver
* Direct driver: report closure sizes when --ot-memory-profiling
An eventlog memory analysis doesnt' seem so relevant since this mode is not
interactive, but we could easily produce both if wanted to
* Everything is reachable from GhcSessionIO, so compute it last
I suspect the ShakeExtras record is reachable from GhcSessionIO
* bound recursion and use logger
* hlint suggestions
* Fix 8.6 build
* Format imports
* Do the memory analysis with full sharing. GhcSessionIO last
* Fail fast in the memory analysis
* error handling
* runHeapsize now takes initSize as an input argument
* Trace Shake sessions
* Reduced frequency for sampling values length
* Drop the -fexternal-interpreter flag in the Windows stack build
* Produce more benchmark artifacts
* Fix stack descriptors to use heapsize-0.2 from Hackage
* Bump to heapsize-0.3.0
* Record completions snippets (#900)
* Add field for RecordSnippets to CachcedCompletion
* Initial version of local record snippets
* Supprt record snippet completion for non local declarations.
* Better integration of local completions with current implementation
* Clean up non-local completions.
* Remove commented code.
* Switch from String to Text
* Remove ununsed definition
* Treat only Records and leave other defintions as is.
* Differentiate Records from Data constructors for external declaration
* Update test to include snippet in local record completions expected list.
* Update completionTest to also compare insertText.
* Add test for record snippet completion for imported records.
* Hlint fixes
* Hlint fixes
* Hlint suggestions.
* Update type.
* Consolidate imports
* Unpack tuple with explicit names
* Idiomatic changes
* Remove unused variable
* Better variable name
* Hlint suggestions
* Handle exhaustive pattern warning
* Add _ to snippet field name suggestions
* Remove type information passed around but not used
* Update to list comprehension style
* Eliminate intermediate function
* HLint suggestions.
* Idiomatic list comprehension
Co-authored-by: Pepe Iborra <pepeiborra@me.com>
* [nix] use gitignore.nix (#920)
* Ignore import list while producing completions (#919)
* Drop any items in explicit import list
* Test if imports not included in explicit list show up in completions
* Update README.md (#924)
* Custom cradle loading (#928)
When using ghcide as a library, it may be desirable to host the hie.yaml file
in a location other than the project root, or even avoid the file system altogether
* Favor `lookupPathToId` over `pathToId` (#926)
* Favor `lookupPathToId` over `pathToId`
* Fix `typecheckParentsAction`
* Fix `needsCompilationRule`
* Return completion snippets only when client supports it (#929)
* Use the real client capabilities on completions
* Return completion snippets only when supported by the client
Restored from https://github.com/haskell/ghcide/pull/900
* Redundant import
* Fix stack windows build
Co-authored-by: Michalis Pardalos <m.pardalos@gmail.com>
Co-authored-by: Michalis Pardalos <mpardalos@gmail.com>
Co-authored-by: Guru Devanla <gdevanla@users.noreply.github.com>
Co-authored-by: Samuel Ainsworth <skainsworth@gmail.com>
2020-12-05 20:44:17 +03:00
|
|
|
let options = (defaultIdeOptions sessionLoader)
|
|
|
|
{ optShakeProfiling = argsShakeProfiling
|
|
|
|
-- , optOTMemoryProfiling = IdeOTMemoryProfiling argsOTMemoryProfiling
|
|
|
|
, optTesting = IdeTesting argsTesting
|
|
|
|
, optThreads = argsThreads
|
2020-12-14 16:37:19 +03:00
|
|
|
, optCheckParents = NeverCheck
|
|
|
|
, optCheckProject = CheckProject False
|
Opentelemetry traces and heapsize memory analysis (#922)
* Move tracing functions to own module
* Bump opentelemetry to 0.6.0
* Write Values map size to OpenTelemetry metric
* Trace all requests and notifications
Instead of doing it in `HoverDefinition`, do it in
with{Response,Notification,...}. These wrap all handlers, so this should
cover everything. It also means that the span covers the entire
processing time for the request, where before we missed the setup
happening in the with* functions.
* Add flag for OpenTelemetry profiling
Run GC regularly with --ot-profiling
* Add flag to enable OT profiling in benchmark
* Use heapsize instead of ghc-datasize
I renamed the fork to distringuish from the original.
It is still being pulled from git using stack. This will be addressed
once I can push the fork to hackage.
* Bump opentelemetry to 0.6.1 - fixes 8.6 build
* Use heapsize from hackage
* Address HLint messages
* Record size of each key independently
* Refactor `startTelemetry` function
* Remove delay between measuring memory loops
* Each key in values map gets own OT instrument
* Measure values map length more rarely
* Rename --ot-profiling to --ot-memory-profiling
* Add docs for how to use the opentelemetry output
* Add instructions to build release version of tracy
* Clarify dependencies in opentelemetry instructions
* Fix LSP traces
* otTraced: delete unused
* Extract types out of D.IDE.Core.Shake
to avoid circular module dependencies
* Extract startTelemetry out of D.IDE.Shake and upgrade to 0.2
No more segfaults
* [nix] install opentelemetry
* [nix] install tracy
* Fix merge wibble
* Measure recursive sizes with sharing
* Sort keys for cost attribution
* Remove debug traces
* Allocate less, group keys, clean up hlints
* Add -A4G to the flags used for --ot-memory-profiling
* Modularize D.IDE.Core.Tracing
I want to reuse this code more directly in the non lsp driver
* Direct driver: report closure sizes when --ot-memory-profiling
An eventlog memory analysis doesnt' seem so relevant since this mode is not
interactive, but we could easily produce both if wanted to
* Everything is reachable from GhcSessionIO, so compute it last
I suspect the ShakeExtras record is reachable from GhcSessionIO
* bound recursion and use logger
* hlint suggestions
* Fix 8.6 build
* Format imports
* Do the memory analysis with full sharing. GhcSessionIO last
* Fail fast in the memory analysis
* error handling
* runHeapsize now takes initSize as an input argument
* Trace Shake sessions
* Reduced frequency for sampling values length
* Drop the -fexternal-interpreter flag in the Windows stack build
* Produce more benchmark artifacts
* Fix stack descriptors to use heapsize-0.2 from Hackage
* Bump to heapsize-0.3.0
* Record completions snippets (#900)
* Add field for RecordSnippets to CachcedCompletion
* Initial version of local record snippets
* Supprt record snippet completion for non local declarations.
* Better integration of local completions with current implementation
* Clean up non-local completions.
* Remove commented code.
* Switch from String to Text
* Remove ununsed definition
* Treat only Records and leave other defintions as is.
* Differentiate Records from Data constructors for external declaration
* Update test to include snippet in local record completions expected list.
* Update completionTest to also compare insertText.
* Add test for record snippet completion for imported records.
* Hlint fixes
* Hlint fixes
* Hlint suggestions.
* Update type.
* Consolidate imports
* Unpack tuple with explicit names
* Idiomatic changes
* Remove unused variable
* Better variable name
* Hlint suggestions
* Handle exhaustive pattern warning
* Add _ to snippet field name suggestions
* Remove type information passed around but not used
* Update to list comprehension style
* Eliminate intermediate function
* HLint suggestions.
* Idiomatic list comprehension
Co-authored-by: Pepe Iborra <pepeiborra@me.com>
* [nix] use gitignore.nix (#920)
* Ignore import list while producing completions (#919)
* Drop any items in explicit import list
* Test if imports not included in explicit list show up in completions
* Update README.md (#924)
* Custom cradle loading (#928)
When using ghcide as a library, it may be desirable to host the hie.yaml file
in a location other than the project root, or even avoid the file system altogether
* Favor `lookupPathToId` over `pathToId` (#926)
* Favor `lookupPathToId` over `pathToId`
* Fix `typecheckParentsAction`
* Fix `needsCompilationRule`
* Return completion snippets only when client supports it (#929)
* Use the real client capabilities on completions
* Return completion snippets only when supported by the client
Restored from https://github.com/haskell/ghcide/pull/900
* Redundant import
* Fix stack windows build
Co-authored-by: Michalis Pardalos <m.pardalos@gmail.com>
Co-authored-by: Michalis Pardalos <mpardalos@gmail.com>
Co-authored-by: Guru Devanla <gdevanla@users.noreply.github.com>
Co-authored-by: Samuel Ainsworth <skainsworth@gmail.com>
2020-12-05 20:44:17 +03:00
|
|
|
}
|
|
|
|
logLevel = if argsVerbose then minBound else Info
|
|
|
|
ide <- initialise def mainRule (pure $ IdInt 0) (showEvent lock) dummyWithProg (const (const id)) (logger logLevel) debouncer options vfs
|
2020-06-02 15:44:16 +03:00
|
|
|
|
|
|
|
putStrLn "\nStep 4/4: Type checking the files"
|
2020-09-11 22:58:23 +03:00
|
|
|
setFilesOfInterest ide $ HashMap.fromList $ map ((, OnDisk) . toNormalizedFilePath') files
|
2020-06-30 12:22:20 +03:00
|
|
|
results <- runAction "User TypeCheck" ide $ uses TypeCheck (map toNormalizedFilePath' files)
|
Opentelemetry traces and heapsize memory analysis (#922)
* Move tracing functions to own module
* Bump opentelemetry to 0.6.0
* Write Values map size to OpenTelemetry metric
* Trace all requests and notifications
Instead of doing it in `HoverDefinition`, do it in
with{Response,Notification,...}. These wrap all handlers, so this should
cover everything. It also means that the span covers the entire
processing time for the request, where before we missed the setup
happening in the with* functions.
* Add flag for OpenTelemetry profiling
Run GC regularly with --ot-profiling
* Add flag to enable OT profiling in benchmark
* Use heapsize instead of ghc-datasize
I renamed the fork to distringuish from the original.
It is still being pulled from git using stack. This will be addressed
once I can push the fork to hackage.
* Bump opentelemetry to 0.6.1 - fixes 8.6 build
* Use heapsize from hackage
* Address HLint messages
* Record size of each key independently
* Refactor `startTelemetry` function
* Remove delay between measuring memory loops
* Each key in values map gets own OT instrument
* Measure values map length more rarely
* Rename --ot-profiling to --ot-memory-profiling
* Add docs for how to use the opentelemetry output
* Add instructions to build release version of tracy
* Clarify dependencies in opentelemetry instructions
* Fix LSP traces
* otTraced: delete unused
* Extract types out of D.IDE.Core.Shake
to avoid circular module dependencies
* Extract startTelemetry out of D.IDE.Shake and upgrade to 0.2
No more segfaults
* [nix] install opentelemetry
* [nix] install tracy
* Fix merge wibble
* Measure recursive sizes with sharing
* Sort keys for cost attribution
* Remove debug traces
* Allocate less, group keys, clean up hlints
* Add -A4G to the flags used for --ot-memory-profiling
* Modularize D.IDE.Core.Tracing
I want to reuse this code more directly in the non lsp driver
* Direct driver: report closure sizes when --ot-memory-profiling
An eventlog memory analysis doesnt' seem so relevant since this mode is not
interactive, but we could easily produce both if wanted to
* Everything is reachable from GhcSessionIO, so compute it last
I suspect the ShakeExtras record is reachable from GhcSessionIO
* bound recursion and use logger
* hlint suggestions
* Fix 8.6 build
* Format imports
* Do the memory analysis with full sharing. GhcSessionIO last
* Fail fast in the memory analysis
* error handling
* runHeapsize now takes initSize as an input argument
* Trace Shake sessions
* Reduced frequency for sampling values length
* Drop the -fexternal-interpreter flag in the Windows stack build
* Produce more benchmark artifacts
* Fix stack descriptors to use heapsize-0.2 from Hackage
* Bump to heapsize-0.3.0
* Record completions snippets (#900)
* Add field for RecordSnippets to CachcedCompletion
* Initial version of local record snippets
* Supprt record snippet completion for non local declarations.
* Better integration of local completions with current implementation
* Clean up non-local completions.
* Remove commented code.
* Switch from String to Text
* Remove ununsed definition
* Treat only Records and leave other defintions as is.
* Differentiate Records from Data constructors for external declaration
* Update test to include snippet in local record completions expected list.
* Update completionTest to also compare insertText.
* Add test for record snippet completion for imported records.
* Hlint fixes
* Hlint fixes
* Hlint suggestions.
* Update type.
* Consolidate imports
* Unpack tuple with explicit names
* Idiomatic changes
* Remove unused variable
* Better variable name
* Hlint suggestions
* Handle exhaustive pattern warning
* Add _ to snippet field name suggestions
* Remove type information passed around but not used
* Update to list comprehension style
* Eliminate intermediate function
* HLint suggestions.
* Idiomatic list comprehension
Co-authored-by: Pepe Iborra <pepeiborra@me.com>
* [nix] use gitignore.nix (#920)
* Ignore import list while producing completions (#919)
* Drop any items in explicit import list
* Test if imports not included in explicit list show up in completions
* Update README.md (#924)
* Custom cradle loading (#928)
When using ghcide as a library, it may be desirable to host the hie.yaml file
in a location other than the project root, or even avoid the file system altogether
* Favor `lookupPathToId` over `pathToId` (#926)
* Favor `lookupPathToId` over `pathToId`
* Fix `typecheckParentsAction`
* Fix `needsCompilationRule`
* Return completion snippets only when client supports it (#929)
* Use the real client capabilities on completions
* Return completion snippets only when supported by the client
Restored from https://github.com/haskell/ghcide/pull/900
* Redundant import
* Fix stack windows build
Co-authored-by: Michalis Pardalos <m.pardalos@gmail.com>
Co-authored-by: Michalis Pardalos <mpardalos@gmail.com>
Co-authored-by: Guru Devanla <gdevanla@users.noreply.github.com>
Co-authored-by: Samuel Ainsworth <skainsworth@gmail.com>
2020-12-05 20:44:17 +03:00
|
|
|
_results <- runAction "GetHie" ide $ uses GetHieAst (map toNormalizedFilePath' files)
|
|
|
|
_results <- runAction "GenerateCore" ide $ uses GenerateCore (map toNormalizedFilePath' files)
|
2019-06-26 19:07:08 +03:00
|
|
|
let (worked, failed) = partition fst $ zip (map isJust results) files
|
2019-09-27 16:18:24 +03:00
|
|
|
when (failed /= []) $
|
|
|
|
putStr $ unlines $ "Files that failed:" : map ((++) " * " . snd) failed
|
2019-06-26 19:07:08 +03:00
|
|
|
|
Opentelemetry traces and heapsize memory analysis (#922)
* Move tracing functions to own module
* Bump opentelemetry to 0.6.0
* Write Values map size to OpenTelemetry metric
* Trace all requests and notifications
Instead of doing it in `HoverDefinition`, do it in
with{Response,Notification,...}. These wrap all handlers, so this should
cover everything. It also means that the span covers the entire
processing time for the request, where before we missed the setup
happening in the with* functions.
* Add flag for OpenTelemetry profiling
Run GC regularly with --ot-profiling
* Add flag to enable OT profiling in benchmark
* Use heapsize instead of ghc-datasize
I renamed the fork to distringuish from the original.
It is still being pulled from git using stack. This will be addressed
once I can push the fork to hackage.
* Bump opentelemetry to 0.6.1 - fixes 8.6 build
* Use heapsize from hackage
* Address HLint messages
* Record size of each key independently
* Refactor `startTelemetry` function
* Remove delay between measuring memory loops
* Each key in values map gets own OT instrument
* Measure values map length more rarely
* Rename --ot-profiling to --ot-memory-profiling
* Add docs for how to use the opentelemetry output
* Add instructions to build release version of tracy
* Clarify dependencies in opentelemetry instructions
* Fix LSP traces
* otTraced: delete unused
* Extract types out of D.IDE.Core.Shake
to avoid circular module dependencies
* Extract startTelemetry out of D.IDE.Shake and upgrade to 0.2
No more segfaults
* [nix] install opentelemetry
* [nix] install tracy
* Fix merge wibble
* Measure recursive sizes with sharing
* Sort keys for cost attribution
* Remove debug traces
* Allocate less, group keys, clean up hlints
* Add -A4G to the flags used for --ot-memory-profiling
* Modularize D.IDE.Core.Tracing
I want to reuse this code more directly in the non lsp driver
* Direct driver: report closure sizes when --ot-memory-profiling
An eventlog memory analysis doesnt' seem so relevant since this mode is not
interactive, but we could easily produce both if wanted to
* Everything is reachable from GhcSessionIO, so compute it last
I suspect the ShakeExtras record is reachable from GhcSessionIO
* bound recursion and use logger
* hlint suggestions
* Fix 8.6 build
* Format imports
* Do the memory analysis with full sharing. GhcSessionIO last
* Fail fast in the memory analysis
* error handling
* runHeapsize now takes initSize as an input argument
* Trace Shake sessions
* Reduced frequency for sampling values length
* Drop the -fexternal-interpreter flag in the Windows stack build
* Produce more benchmark artifacts
* Fix stack descriptors to use heapsize-0.2 from Hackage
* Bump to heapsize-0.3.0
* Record completions snippets (#900)
* Add field for RecordSnippets to CachcedCompletion
* Initial version of local record snippets
* Supprt record snippet completion for non local declarations.
* Better integration of local completions with current implementation
* Clean up non-local completions.
* Remove commented code.
* Switch from String to Text
* Remove ununsed definition
* Treat only Records and leave other defintions as is.
* Differentiate Records from Data constructors for external declaration
* Update test to include snippet in local record completions expected list.
* Update completionTest to also compare insertText.
* Add test for record snippet completion for imported records.
* Hlint fixes
* Hlint fixes
* Hlint suggestions.
* Update type.
* Consolidate imports
* Unpack tuple with explicit names
* Idiomatic changes
* Remove unused variable
* Better variable name
* Hlint suggestions
* Handle exhaustive pattern warning
* Add _ to snippet field name suggestions
* Remove type information passed around but not used
* Update to list comprehension style
* Eliminate intermediate function
* HLint suggestions.
* Idiomatic list comprehension
Co-authored-by: Pepe Iborra <pepeiborra@me.com>
* [nix] use gitignore.nix (#920)
* Ignore import list while producing completions (#919)
* Drop any items in explicit import list
* Test if imports not included in explicit list show up in completions
* Update README.md (#924)
* Custom cradle loading (#928)
When using ghcide as a library, it may be desirable to host the hie.yaml file
in a location other than the project root, or even avoid the file system altogether
* Favor `lookupPathToId` over `pathToId` (#926)
* Favor `lookupPathToId` over `pathToId`
* Fix `typecheckParentsAction`
* Fix `needsCompilationRule`
* Return completion snippets only when client supports it (#929)
* Use the real client capabilities on completions
* Return completion snippets only when supported by the client
Restored from https://github.com/haskell/ghcide/pull/900
* Redundant import
* Fix stack windows build
Co-authored-by: Michalis Pardalos <m.pardalos@gmail.com>
Co-authored-by: Michalis Pardalos <mpardalos@gmail.com>
Co-authored-by: Guru Devanla <gdevanla@users.noreply.github.com>
Co-authored-by: Samuel Ainsworth <skainsworth@gmail.com>
2020-12-05 20:44:17 +03:00
|
|
|
let nfiles xs = let n = length xs in if n == 1 then "1 file" else show n ++ " files"
|
|
|
|
putStrLn $ "\nCompleted (" ++ nfiles worked ++ " worked, " ++ nfiles failed ++ " failed)"
|
|
|
|
|
|
|
|
when argsOTMemoryProfiling $ do
|
|
|
|
let valuesRef = state $ shakeExtras ide
|
|
|
|
values <- readVar valuesRef
|
|
|
|
let consoleObserver Nothing = return $ \size -> printf "Total: %.2fMB\n" (fromIntegral @Int @Double size / 1e6)
|
|
|
|
consoleObserver (Just k) = return $ \size -> printf " - %s: %.2fKB\n" (show k) (fromIntegral @Int @Double size / 1e3)
|
|
|
|
|
|
|
|
printf "# Shake value store contents(%d):\n" (length values)
|
|
|
|
let keys = nub
|
|
|
|
$ Key GhcSession : Key GhcSessionDeps
|
|
|
|
: [ k | (_,k) <- HashMap.keys values, k /= Key GhcSessionIO]
|
|
|
|
++ [Key GhcSessionIO]
|
|
|
|
measureMemory (logger logLevel) [keys] consoleObserver valuesRef
|
|
|
|
|
ShakeSession and shakeEnqueue (#554)
* ShakeSession and shakeRunGently
Currently we start a new Shake session for every interaction with the Shake
database, including type checking, hovers, code actions, completions, etc.
Since only one Shake session can ever exist, we abort the active session if any
in order to execute the new command in a responsive manner.
This is suboptimal in many, many ways:
- A hover in module M aborts the typechecking of module M, only to start over!
- Read-only commands (hover, code action, completion) need to typecheck all the
modules! (or rather, ask Shake to check that the typechecks are current)
- There is no way to run non-interfering commands concurrently
This is an experiment inspired by the 'ShakeQueue' of @mpickering, and
the follow-up discussion in https://github.com/mpickering/ghcide/issues/7
We introduce the concept of the 'ShakeSession' as part of the IDE state.
The 'ShakeSession' is initialized by a call to 'shakeRun', and survives until
the next call to 'shakeRun'. It is important that the session is restarted as
soon as the filesystem changes, to ensure that the database is current.
The 'ShakeSession' enables a new command 'shakeRunGently', which appends work to
the existing 'ShakeSession'. This command can be called in parallel without any
restriction.
* Simplify by assuming there is always a ShakeSession
* Improved naming and docs
* Define runActionSync on top of shakeEnqueue
shakeRun is not correct as it never returns anymore
* Drive progress reporting from newSession
The previous approach reused the shakeProgress thread, which doesn't work anymore as ShakeSession keeps the ShakeDatabase open until the next edit
* Deterministic progress messages in tests
Dropping the 0.1s sleep to ensure that progress messages during tests are
deterministic
* Make kick explicit
This is required for progress reporting to work, see notes in shakeRun
As to whether this is the right thing to do:
1. Less magic, more explicit
2. There's only 2 places where kick is actually used
* apply Neil's feedback
* avoid a deadlock when the enqueued action throws
* Simplify runAction + comments
* use a Barrier for clarity
A Barrier is a smaller abstraction than an MVar, and the next version of the extra package will come with a suitably small implementation:
https://github.com/ndmitchell/extra/commit/98c2a83585d2ca0a9d961dd241c4a967ef87866a
* Log timings for code actions, hovers and completions
* Rename shakeRun to shakeRestart
The action returned by shakeRun now blocks until another call to shakeRun is made, which is a change in behaviour,. but all the current uses of shakeRun ignore this action.
Since the new behaviour is not useful, this change simplifies and updates the docs and name accordingly
* delete runActionSync as it's just runAction
* restart shake session on new component created
* requeue pending actions on session restart
* hlint
* Bumped the delay from 5 to 6
* Add a test for the non-lsp command line
* Update exe/Main.hs
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-06-08 12:36:36 +03:00
|
|
|
unless (null failed) (exitWith $ ExitFailure (length failed))
|
2019-06-13 19:21:27 +03:00
|
|
|
|
Opentelemetry traces and heapsize memory analysis (#922)
* Move tracing functions to own module
* Bump opentelemetry to 0.6.0
* Write Values map size to OpenTelemetry metric
* Trace all requests and notifications
Instead of doing it in `HoverDefinition`, do it in
with{Response,Notification,...}. These wrap all handlers, so this should
cover everything. It also means that the span covers the entire
processing time for the request, where before we missed the setup
happening in the with* functions.
* Add flag for OpenTelemetry profiling
Run GC regularly with --ot-profiling
* Add flag to enable OT profiling in benchmark
* Use heapsize instead of ghc-datasize
I renamed the fork to distringuish from the original.
It is still being pulled from git using stack. This will be addressed
once I can push the fork to hackage.
* Bump opentelemetry to 0.6.1 - fixes 8.6 build
* Use heapsize from hackage
* Address HLint messages
* Record size of each key independently
* Refactor `startTelemetry` function
* Remove delay between measuring memory loops
* Each key in values map gets own OT instrument
* Measure values map length more rarely
* Rename --ot-profiling to --ot-memory-profiling
* Add docs for how to use the opentelemetry output
* Add instructions to build release version of tracy
* Clarify dependencies in opentelemetry instructions
* Fix LSP traces
* otTraced: delete unused
* Extract types out of D.IDE.Core.Shake
to avoid circular module dependencies
* Extract startTelemetry out of D.IDE.Shake and upgrade to 0.2
No more segfaults
* [nix] install opentelemetry
* [nix] install tracy
* Fix merge wibble
* Measure recursive sizes with sharing
* Sort keys for cost attribution
* Remove debug traces
* Allocate less, group keys, clean up hlints
* Add -A4G to the flags used for --ot-memory-profiling
* Modularize D.IDE.Core.Tracing
I want to reuse this code more directly in the non lsp driver
* Direct driver: report closure sizes when --ot-memory-profiling
An eventlog memory analysis doesnt' seem so relevant since this mode is not
interactive, but we could easily produce both if wanted to
* Everything is reachable from GhcSessionIO, so compute it last
I suspect the ShakeExtras record is reachable from GhcSessionIO
* bound recursion and use logger
* hlint suggestions
* Fix 8.6 build
* Format imports
* Do the memory analysis with full sharing. GhcSessionIO last
* Fail fast in the memory analysis
* error handling
* runHeapsize now takes initSize as an input argument
* Trace Shake sessions
* Reduced frequency for sampling values length
* Drop the -fexternal-interpreter flag in the Windows stack build
* Produce more benchmark artifacts
* Fix stack descriptors to use heapsize-0.2 from Hackage
* Bump to heapsize-0.3.0
* Record completions snippets (#900)
* Add field for RecordSnippets to CachcedCompletion
* Initial version of local record snippets
* Supprt record snippet completion for non local declarations.
* Better integration of local completions with current implementation
* Clean up non-local completions.
* Remove commented code.
* Switch from String to Text
* Remove ununsed definition
* Treat only Records and leave other defintions as is.
* Differentiate Records from Data constructors for external declaration
* Update test to include snippet in local record completions expected list.
* Update completionTest to also compare insertText.
* Add test for record snippet completion for imported records.
* Hlint fixes
* Hlint fixes
* Hlint suggestions.
* Update type.
* Consolidate imports
* Unpack tuple with explicit names
* Idiomatic changes
* Remove unused variable
* Better variable name
* Hlint suggestions
* Handle exhaustive pattern warning
* Add _ to snippet field name suggestions
* Remove type information passed around but not used
* Update to list comprehension style
* Eliminate intermediate function
* HLint suggestions.
* Idiomatic list comprehension
Co-authored-by: Pepe Iborra <pepeiborra@me.com>
* [nix] use gitignore.nix (#920)
* Ignore import list while producing completions (#919)
* Drop any items in explicit import list
* Test if imports not included in explicit list show up in completions
* Update README.md (#924)
* Custom cradle loading (#928)
When using ghcide as a library, it may be desirable to host the hie.yaml file
in a location other than the project root, or even avoid the file system altogether
* Favor `lookupPathToId` over `pathToId` (#926)
* Favor `lookupPathToId` over `pathToId`
* Fix `typecheckParentsAction`
* Fix `needsCompilationRule`
* Return completion snippets only when client supports it (#929)
* Use the real client capabilities on completions
* Return completion snippets only when supported by the client
Restored from https://github.com/haskell/ghcide/pull/900
* Redundant import
* Fix stack windows build
Co-authored-by: Michalis Pardalos <m.pardalos@gmail.com>
Co-authored-by: Michalis Pardalos <mpardalos@gmail.com>
Co-authored-by: Guru Devanla <gdevanla@users.noreply.github.com>
Co-authored-by: Samuel Ainsworth <skainsworth@gmail.com>
2020-12-05 20:44:17 +03:00
|
|
|
{-# ANN main ("HLint: ignore Use nubOrd" :: String) #-}
|
|
|
|
|
2019-06-26 19:07:08 +03:00
|
|
|
expandFiles :: [FilePath] -> IO [FilePath]
|
|
|
|
expandFiles = concatMapM $ \x -> do
|
|
|
|
b <- IO.doesFileExist x
|
|
|
|
if b then return [x] else do
|
|
|
|
let recurse "." = True
|
|
|
|
recurse x | "." `isPrefixOf` takeFileName x = False -- skip .git etc
|
|
|
|
recurse x = takeFileName x `notElem` ["dist","dist-newstyle"] -- cabal directories
|
2020-02-17 12:33:33 +03:00
|
|
|
files <- filter (\x -> takeExtension x `elem` [".hs",".lhs"]) <$> IO.listFilesInside (return . recurse) x
|
2019-06-26 19:07:08 +03:00
|
|
|
when (null files) $
|
|
|
|
fail $ "Couldn't find any .hs/.lhs files inside directory: " ++ x
|
|
|
|
return files
|
|
|
|
|
2019-05-20 18:36:08 +03:00
|
|
|
-- | Print an LSP event.
|
2019-06-11 17:03:44 +03:00
|
|
|
showEvent :: Lock -> FromServerMessage -> IO ()
|
|
|
|
showEvent _ (EventFileDiagnostics _ []) = return ()
|
2020-03-23 11:07:04 +03:00
|
|
|
showEvent lock (EventFileDiagnostics (toNormalizedFilePath' -> file) diags) =
|
2019-12-17 17:13:12 +03:00
|
|
|
withLock lock $ T.putStrLn $ showDiagnosticsColored $ map (file,ShowDiag,) diags
|
2019-05-20 18:36:08 +03:00
|
|
|
showEvent lock e = withLock lock $ print e
|