ghcide/exe/Arguments.hs

42 lines
1.7 KiB
Haskell
Raw Normal View History

2019-08-13 19:23:03 +03:00
-- Copyright (c) 2019 The DAML Authors. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Arguments(Arguments(..), getArguments) where
import Options.Applicative
data Arguments = Arguments
{argLSP :: Bool
,argsCwd :: Maybe FilePath
,argFiles :: [FilePath]
,argsVersion :: Bool
,argsShakeProfiling :: Maybe FilePath
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
,argsOTMemoryProfiling :: Bool
,argsTesting :: Bool
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
,argsDisableKick :: Bool
,argsThreads :: Int
,argsVerbose :: Bool
}
getArguments :: IO Arguments
getArguments = execParser opts
where
opts = info (arguments <**> helper)
( fullDesc
<> progDesc "Used as a test bed to check your IDE will work"
<> header "ghcide - the core of a Haskell IDE")
arguments :: Parser Arguments
arguments = Arguments
<$> switch (long "lsp" <> help "Start talking to an LSP server")
<*> optional (strOption $ long "cwd" <> metavar "DIR" <> help "Change to this directory")
<*> many (argument str (metavar "FILES/DIRS..."))
<*> switch (long "version" <> help "Show ghcide and GHC versions")
<*> optional (strOption $ long "shake-profiling" <> metavar "DIR" <> help "Dump profiling reports to this directory")
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
<*> switch (long "ot-memory-profiling" <> help "Record OpenTelemetry info to the eventlog. Needs the -l RTS flag to have an effect")
<*> switch (long "test" <> help "Enable additional lsp messages used by the testsuite")
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
<*> switch (long "test-no-kick" <> help "Disable kick. Useful for testing cancellation")
<*> option auto (short 'j' <> help "Number of threads (0: automatic)" <> metavar "NUM" <> value 0 <> showDefault)
<*> switch (long "verbose" <> help "Include internal events in logging output")