Commit Graph

51 Commits

Author SHA1 Message Date
Michael Peyton Jones
8f0d940445
Document exception handling in Actions/Rules (#3407)
* Document exception handling in Actions/Rules

I also took the liberty of removing the `MonadFail` instance for
`Rules`, since failing in `Rules` seems much worse as it won't
automatically be caught. There was only one use of that, which now has
an appropriately threatening comment.

* Tweak

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-01-02 12:51:56 +00:00
Zubin Duggal
2df68246f8 Prepare release 1.9.0.0 2022-12-26 16:09:25 +05:30
Ruslan Gadeev
5d56aa70a8
fix typos (#3325)
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
2022-11-09 17:42:12 +00:00
Zubin Duggal
94cd24d9e4 Fix testing hls-graph 2022-10-24 14:50:37 +05:30
Zubin Duggal
3b64a3b1c5 Introduce KeyMap and KeySet 2022-10-24 14:50:37 +05:30
Zubin Duggal
ada1b3dc13 hls-graph - avoid duplicating key texts 2022-10-24 14:50:37 +05:30
wz1000
eafda04529 Update hls-graph/src/Development/IDE/Graph/Internal/Types.hs
Co-authored-by: Pepe Iborra <pepeiborra@gmail.com>
2022-10-24 14:50:37 +05:30
Zubin Duggal
e99772d2d7 Implement sharing for hls-graph Keys 2022-10-24 14:50:37 +05:30
Andy
86e3fd6c65
Cleanup GHC macros (because min version is 8.8.4) (#3281)
* Drop min_version_ghc (8.8.4 is min supported)

* Drop conditional glasgow_haskell cpp

* Inline some imports (review feedback)

* Drop hie-compat 8.6 (review feedback)

* Dropping more ghc 8.6 related code and docs

* Eval: Include tests that were broken for 8.6
2022-10-11 22:35:18 +00:00
Pepe Iborra
9b491f7bbf
Drop compatibility with GHC 8.6.5 (#3101)
* Drop compatibility with GHC 8.6.5

* drop a few more bits

* fixup merge

Co-authored-by: Javier Neira <atreyu.bbb@gmail.com>
2022-10-11 12:18:49 +00:00
Andy
21c8e9b83e
Hlint: A handful of fixes to hints (#3259)
* CI: rwe/actions-hlint-run v2

* fmt script: Fix missing directories

Otherwise will fail

* Hlint: Automatically fix warnings via apply-refact

* Hlint: Do not suggest fromMaybe

Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
2022-10-10 11:47:42 +00:00
Pepe Iborra
4ce8f99bcd
Remove unused build-depends and install warnings (#3155)
* Remove unused build-depends and install warnings

* Remove -Werror
2022-09-15 10:44:02 +01:00
Zubin Duggal
816cd6301e Prepare 1.8.0.0
Use hiedb from hackage

gitlab-ci: remove workaround for windows 9.2.2
gitlab-ci: remove workaround for windows 9.2.2

hie-bios

update hie bios

update hie bios

bounds

hie-bios fixes

hie-bios fixes

lsp 1.6

cabal.project fixes

hie-bios fixes

lsp and hie-bios from hackage

Mark hie-bios error as expectFail

hie-bios fixes

hie-bios fixes

Stack

Stack

stack fixes
2022-09-14 02:27:17 +05:30
Zubin Duggal
a9f1c538ac Remove exactprint dependencies from ghcide by introducing hls-refactor-plugin.
All code actions have been moved to hls-refactor-plugin

Mostly straightforward, only slight complication was that completion auto imports
depends on exactprint, but I didn't want to remove all completion logic from ghcide
just for this.

Instead, I added logic to dynamically lookup the plugin that provides
the extend import command, so that auto imports work as expected when you have
hls-refactor-plugin enabled.

Move lookupPluginId out of loop

Replace code actions with lenses in benchmarks

Allow plugins to use GetAnnotatedParsedSource by linking it in when depended on

Move lookupPluginId to IdePlugins

Add default extensions

Move traceAst
2022-08-31 00:56:35 +05:30
Dmitry Pogodin
347a7187f2
Run pre-commit hooks (#3059) 2022-07-28 16:48:13 +00:00
ˌbodʲɪˈɡrʲim
ffefe761c8
hls-graph: add lower bound for async (#3021)
`Control.Concurrent.Async` is not available before `async-2.0`

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-07-06 23:17:38 +00:00
Michael Peyton Jones
510bd51e46
Remove some partial functions from Shake.hs (#2986)
Also removes a partial pattern match from Action.hs.
2022-06-29 09:00:49 +01:00
Zubin Duggal
c047b052b1 Generate bytecode/object code on demand
Adds a new rule `GetLinkable` which is called on demand by
hscCompileCoreExprHook whenever a linkable is required for a splice.

Adds a MonadUnliftIO instance for Action to faciliate the above

We write Core Files whenever a linkable could potentially be required for a file
(i.e it is in the transitive closure of a module that uses TH/compile time code
execution)

However, we only generate byte/object code when such a linkable is
really required by a splice (i.e. the module is in the transitive closure
of any symbol called from a splice).

No linkables are stored in `HiFileResult`. If a linkable is required, then
it must be obtained via a call to `GetLinkable`.

Also use hashes to do fine grained recompilation checking for TH instead of
mod times. This simplifies recompilation checking quite a bit.
2022-06-20 02:31:10 +05:30
Pepe Iborra
6524122927
Expose runtime metrics via EKG (#2267)
* Collect metrics and expose an EKG server

* register gc metrics locally

* getDatabaseKeys

* fixups

* Abstract monitoring and put EKG behind a Cabal flag

* Add CI for the new flag

* fix double ifdef

* link to GHC docs for eventlogs

* log when stopping the EKG server

* Allow CPP in modules

* Add doc comments

* Apply suggestions from code review

Co-authored-by: Michael Peyton Jones <me@michaelpj.com>

* Compat. with ghc 9.2

* use an ekg-json snapshot that preserves compat. with ghc 8.x

* confine CPP to the EKG module

Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
2022-05-06 09:58:18 +00:00
Zubin Duggal
41b30b5706 Prepare 1.7.0.0 2022-04-21 14:08:10 +05:30
Pepe Iborra
8466bc11a6
work on the sync computations first (#2805) 2022-03-29 12:22:24 +00:00
Pepe Iborra
30d48ed705
Fix 2 space leaks (#2774)
* Fix a space leak in hls-graph

* Fix leak in ExportsMap and optimize
2022-03-15 19:13:00 +00:00
Pepe Iborra
fbbf76b146
Review masking and add traces when things don't cancel timely (#2768)
* Review masking and add traces when things don't cancel timely

* fixup

* use sleep consistently

* redundant imports

* hlints

* fix 9.2 build

* Fix 9.2 build for real

* remove unnecessary polymorphism

* Avoid spawning loop async unnecessrily

* flush asyncs ref

* Add comments and apply @michaelpj suggestions
2022-03-11 10:35:37 +00:00
Pepe Iborra
6a8dc225ae
Implement cycle detection in hls-graph (#2756) 2022-03-08 10:34:57 +00:00
Pepe Iborra
30b3fec2f0
Adjust rendering of error logs and drop unneeded MonadUnliftIO instance (#2755)
* drop unneeded MonadUnliftIO instance

* Adjust error message

* fixups
2022-03-06 14:29:20 +00:00
Pepe Iborra
b7f37ad2be
Estimate file versions safely (#2753)
* applyWithoutDependency

* delete dead code

* estimateFileVersionUnsafely

For a long time, defineEarlyCutoff has been accessing the Values store directly
to compute GetModificationTime values instead of calling use, breaking the
invariant. The values are used to associate the rule result to a file version,
which gets recorded in the Value as well as used as the key in the Diagnostics
store.

The problem here is that the GetModificationTime rule computes a new version and
mutates the Values store, so if defineEarlyCutoff peeks in the store before
GetModificationTime has run, it will grab the old version. This leads to lost
diagnostics and potentially to misversioned Values

Fixing the problem is tricky, because we cannot simply use GetModificationTime
inside defineEarlyCutoff for all rules. There are three issues:

1. Creating a dependency on GetModificationTime. If everything depends on it,
then we lose the ability to do early cutoff
2. Creating cycles in the build graph, since GetModificationTime has
dependencies itself. Because hls-graph doesn't implement cycle detection (Shake
did), it is a nightmare to debug these cycles.
3. Creating overhead, since GetModification time calls the file system for non
FOIs and in the past this was very expensive for projects with large cartesian
product of module paths and source folders

To work around these I had to introduce a new hls-graph primitive,
applyWithoutDependency, as well as do a bunch of fragile type tests on the key
type to decide on whether to use GetModificationTime or peek into the values
store. The type casts could be cleaned up by introducing a type class, but I'm
not sure the end result would be any better.

To understand the issue and debug the implementation of the fix, I added a
number of opentelemety traces which I'm leaving in place in case they could be
useful in the future.

* Traces for diagnostics

* handle the empty file path

* return Nothing instead of peeking the store
2022-03-06 11:10:21 +00:00
Pepe Iborra
5afb0770c9
LSP window message log recorder (#2750)
* failing to set the unsafe dynflags is an error

* makeLspRecorder

* include link to the issue tracker

* avoid double popup

* catch another ghc lib dir error
2022-03-06 09:18:46 +00:00
Nick Suchecki
411db02883
Add pre-commit hook for cleaning up mixed-line endings (#2679)
* Update pre-commit hook to include changing line endings

* Fix non-lf lines

* Check pre-commit excludes files

* Revert "Check pre-commit excludes files"

This reverts commit 7b9670f863.

* Actually add the exclude to contributing docs

* Fix merge failure with previous patch

* Inadvertently overwrote merge

* Add LF option for stylish-haskell and pre-commit file

Co-authored-by: Anton Latukha <anton.latukha@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-02-04 14:50:18 +00:00
Javier Neira
ce41b6459a
Prepare 1.6.0 release (#2642)
* Add list of merged prs

* Remove branch trigger

* Update release instructions

* Include 9.2.1 in the current release

* Bump up hls version

* remove duplicate mention

* Remove references to branch name

* Fix cabal.project gen

* Correct fail-fast condition

* Bump up minor version

* Bump up major version

* Bump up major version

* Allow brittany only for 9.0.1

* brittany not supported in hackage and 9.0.2

* Not short hls for hackage

* Bump up versions everywhere

* Update hackage index

* Add ghcide in rename plugin

* Apply linter and add selection demo

* Add header linkable

* Add first version of release description

* Add last prs

* Mention wingman

* Grammar corrections

Co-authored-by: Jan Hrcek <2716069+jhrcek@users.noreply.github.com>

* Correct mention

Co-authored-by: Pepe Iborra <pepeiborra@me.com>

* Warn about th in docs

* Remove reference to install doc

* Rephrasing

Co-authored-by: J. S. <document_done@hotmail.com>

* Better style

Co-authored-by: Junyoung "Clare" Jang <jjc9310@gmail.com>

* Use could to stress it likely will not work

* REmove reliable from the warning

* Reorder comments

* Rephrasing

Co-authored-by: Michael Peyton Jones <me@michaelpj.com>

* Update docs/supported-versions.md

Co-authored-by: Michael Peyton Jones <me@michaelpj.com>

* Use last version of internal deps

* Restore original wording

* One more pr

* One more pr

Co-authored-by: Jan Hrcek <2716069+jhrcek@users.noreply.github.com>
Co-authored-by: Pepe Iborra <pepeiborra@me.com>
Co-authored-by: J. S. <document_done@hotmail.com>
Co-authored-by: Junyoung "Clare" Jang <jjc9310@gmail.com>
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
2022-01-28 09:06:56 +00:00
bradrn
f33954ec38
Correct issues with pre-commit hook (#2597)
* Reformat in accordance with pre-commit hook

* Typo fix: add missing comma to documented pre-commit hook

* Exclude failing files from pre-commit hook

'stylish-haskell' seems to always fail with a parse error on several
files under ghcide/. Excluding these files from the pre-commit hook
ensures that this hook can always succeed.

* Add stylish-haskell excludes to Nix pre-commit hook

* Reformat again in accordance with pre-commit hook

This is basically the same as 800c165, but applied to new changes
which have been added since then.

Co-authored-by: Javier Neira <atreyu.bbb@gmail.com>
2022-01-24 00:58:22 +00:00
Javier Neira
255803531a
Make work stack-9.2.1.yaml and enable pedantic (-WError) for cabal (#2606)
* Enable brittany for ghc-9.0.2

* Make works using cabal freeze

* Add stack 9.2.1 to ci

* Use new *molu versions

* Enable rename for stack 9.2.1

* Use last ghc-lib

* Use correct boot pkgs

* Use last ghc-exactprint

* Reorganize and use lens-5.1

* update retrie

* Comment class plugin package

* Handle Nothing case

* Restore ghc-typelits deps

* More non-exhaustive patterns

* More non-exhaustive patterns

* Set pedantic (-WError) true for cabal

* Remove pedantic as we set it out in cabal.project

* Not set pedantic for ghc-9.2.1

* Set pedantic in cabal.project's

* More non-exhaustive patterns

* Not set pedantic for ghc-9.0.1

* More incomplete patterns

* Fix WErrors

* Dodgy import

* Correct CPP conditions

* Not MonadFail in Prelude

* Fix more warnings

* Restore missing fun

* unused imports

* Enable refine imports

* more fixes

* Enable brittany in nix for 9.0.1

* Use newer prettyprinter

* Return to master

* Enable tactics in stack-9.2.1.yaml

* Enable pedantic in ci

* Avoid deprecation warning with CPP �

* Use default prettyprinter

* Update refinery for ghc-9.2.1

* Ignore deprecations

* Use dev version of ghc-source-gen

* disable wingman for 9.2.1

* Enable wingman for 9.0.2

* disable tactic with flag

* yaml grammar

* Use setup-build action

* Correct workflow

* Build flags for al major os's

* The integer twaek is needed for the solver

* Disable tests beforehand

* flags only affect local packages

* Exclude 8.6.5

* Exclude 8.8.4
2022-01-20 12:38:21 +00:00
Pepe Iborra
4386396624
Build with GHC 9.2 (#2503)
* WIP

* progress

* enable 9.2 in CI

* Sort out some compatibility issues (#2511)

* fix mkPrintUnqualifiedDefault

* fix qualified idents

* Fix a few more ghc compats

* Add new orphans

* Fix runtime APIs

* HsParsedModule

* export GHC.Hs.Utils

* 9.2 compat for unloading and hie file generation

* hlint fix

* Remove 'setupFinderCache' as its never actually used

* 9.2 compat for Development.IDE.Core.Compile

* Stub out 'getDocumentation' on GHC 9.2 (Requires a reimplementation in terms of in-tree annotations)

* Expose binds

* Remove a bit of CPP by refactoring it into Compat layer

* Progress on ghc-exactprint stuff

The Exactprint module compiles, but code actions are the next focus.

* Fix compile on 8.10

* 9.2 compat for CodeAction Exactprint

* 9.2 compat for Outline

* 9.2 compat for Pragmas plugin

* Get the rest compiling with 9.2

* WIP: PLEASE, DROP THIS COMMIT BEFORE MERGE

This hook starts caching pipeline inside of the PR.
If this got merged - all PRs would start to run caching workflow (which is
undesirable, because of platform limitations)

* disabling {test,bench} to properly heat-up the cache

`index-state` change means nothing, but allow to run increment action on
dependency cache pile (as otherwise cache stays idempotent to its key id).

* CI: index-state: +1s refresh

Somehow previous run got early termination. Seems like some GitHub bug, since
cache-hit promises to True only on direct key hit (& we had indirect).

Maybe second time the charm.

* CI: fix early termination

GitHub accepted previous code, & did passed the steps, but somehow ... long
story short, it was pretending to have early termination working, while it just
was always skipping those steps silently.

So, `index-state` needs another +1s.

* WIP: PLEASE, DROP BEFORE MERGE

* WIP: PLEASE, DROP BEFORE MERGE

This reverts commit 064a9b7995.

* WIP: PLEASE, DROP THIS COMMIT BEFORE MERGE

This reverts commit 208f4844f4.

* WIP: PLEASE, DROP THIS COMMIT BEFORE MERGE

This reverts commit ba4d618ba5.

* CI: index-state advance to save cache anew

* CI: apparently GitHub uses alias cp='cp -i'

Another day, another bug.

* WIP: PLESE, REVERT TO TEST ALL GHCs

* CI: index-state +1s

* WIP: PLESE, REVERT TO TEST ALL GHCs

* CI: index-state +1s

* WIP: PLESE, REVERT TO PASS HLINT CI REQUIREMENTS

* Enable tests for ghc-9.2.1

* Use cabal-ghc921.project

* Enable tests for all ghcs

To check changes for ghc-9.2.1 do not break other ghcs

* Address or skip hlint

* Last hlint fixes

* Fix loop when setting DynFlags

* Filter out evidence variables in documentHighlight

* Fix getFlds

* fix GRE

* fix formatting

* fix Compat build in 9.0

* fix collectHsBindsBinders

* remove redundant WarnMsg local typedef

* showSDocForUser

* redundant import

* HsLet

* LetStmt

* fix Completions build

* bump cabal index state

* Literals: replace argument patterns by field patterns

Sadly this is not enough to fix the build

* QualifyImportedNames: fix build with ghc <9.2

* fix <9.2 build Splice plugin

* fix <9.2 build QualifyImportedNames plugin

* Fix <9.2 build Wingman

* fix build example

* Disable a whole bunch of plugins

* Move windows test into the matrix

* Make consistent plugin handling

package commented out <-> flags <-> test suite

* Add a not working stack.yaml for ghc-9.2.1

It starts to build though

* Remove wrong comma

* Restore primitive allow-*

* Use correct UnitId when constructing InstalledModules

* Fix 8.8 build

* Fix hls-test-utils

* Build explicit imports plugin

* Drop Windows build blocked on unix-compat

* bump Cabal index and simplify constraints

* Add comment

* Use GhcSessionDeps in getHieAst

* Use hsConDeclsBinders in Outline generation

* Use the right session in typecheckModule

* Restore some cases in Outline

* Fix Outline build with GHC <9.2

* Remove noisy logMessage notifications in tests

I have never found these useful and they make it much harder to read logs. If there is a test that needs them, please use a custom logger instead of forcing this madness on everyone.

* Build ghcide test and bench suites with 9.2

* Revert "Merge branch 'master' into ghc-9.2"

This reverts commit daf43c86e8, reversing
changes made to f951004021.

* The redundant constraints warning has changed in 9.2

* Fix code action regression

* fix 9.2 ghcide build

* Fix completion snippets

* Fix mismerge

* Bifunctor instance for GenLocated

* Build rename plugin with GHC 9.2

* Helpers for tracing ExactPrint ASTs

* Fix exactprint code actions

* Enable import lens plugin

* WIP test run changes

* Fix GHC 9 build

* Undo WIP test changes

* Fix GHC 8.8 build

* Fix 8.6 build

* Fix another exactprint regression

* Add source repository with ghc-exactprint fixes

* Add source repository for retrie (needed for fixed ghc-exactprint)

* fix ghc <9.2 build

* Another exactprint fix

* Fix benchmarks

* Another exactprint fix

* Disable a plugin test (plugin not compatible anymore)

* Enable windows build

* Fix multiple components by using consistent UnitIds

There are multiple sources of truth for the home unit id now, in the DynFlags and in the hsc_units

* Improve error handling for initPlugins

* Fix two hover tests

* Remove retrie and ghc-exactprint source repos

* Fix version of direct-sqlite

Not sure why this is needed, but without it Cabal is selecting an older version
which fails to build with 9.2

* Fix ci update hackage index

* This test is broken because GHC 9.2 built-in libraries lack docs

The interface files have no docs, checked via:

    ghc --show-iface ~/.ghcup/ghc/9.2.1/lib/ghc-9.2.1/lib/x86_64-osx-ghc-9.2.1/base-4.16.0.0/Data/Functor.hi

* Sanitize hiding tests

These tests are reimplementing runWithExtraFiles - let's just use it

* Disable another test

* Fix outline

* Revert "Sanitize hiding tests"

This reverts commit 4f016ddca2.

* Extract out ci build setup

* Correct action path

* Add required shell property

* Remove unused cabal version

* Update .github/actions/setup-build/action.yml

Co-authored-by: Michael Peyton Jones <me@michaelpj.com>

* Update .github/actions/setup-build/action.yml

Co-authored-by: Michael Peyton Jones <me@michaelpj.com>

* Update .github/actions/setup-build/action.yml

Co-authored-by: Michael Peyton Jones <me@michaelpj.com>

* Fix remaining tests and some warnings

* Update .github/actions/setup-build/action.yml

Co-Authored-By: @michaelpj

* Copy alt project file unconditionally

* Make freeze strict

* Actually fix tests

* remove unnecessary? allow-newer

* Drop no longer needed source repo for th-extras

* Add module header comments

* Fix or remove commented out code

* more commented out code

* Disable a couple of func-test tests

* All func-test tests passing now

* fix test matrix

* Update cabal-ghc921.project

* do not test class plugin

* Mark hover test broken in Windows and Mac

* Fix hls-pragmas-plugin test suite

* disable testing of refine imports plugin

* disable rename plugin

* Do not test qualify imported names plugin

* addressing hlint suggestions

* Revert hlint change that breaks due to CPP

Co-authored-by: Alan Zimmerman <alan.zimm@gmail.com>
Co-authored-by: Zubin Duggal <zubin.duggal@gmail.com>
Co-authored-by: Anton Latukha <anton.latukha@gmail.com>
Co-authored-by: jneira <atreyu.bbb@gmail.com>
Co-authored-by: Junyoung "Clare" Jang <jjc9310@gmail.com>
Co-authored-by: Matthew Pickering <matthewtpickering@gmail.com>
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
2022-01-12 21:57:36 +00:00
Pepe Iborra
46dfbd1480
Restore TemplateHaskell pragma in hls-graph (#2549)
* restore TemplateHaskell pragma

not 9.2 specific, but required for file_embed flag

* CI: add flags workflow

* hls-graph: STM.Stats: fx stm-stats build

* hls-graph: Internal.Types: mk 8.6.5 code as such

* hls-graph: Internal.Types: treat MonadFail

* CI: {caching, test, bench, flags}: fx freeze phase

* hls-graph: Internal.Types: fx TVar import

* CI: {caching, test, bench, flags}: ('' -> "")

Tripped-over the syntax highlighting & the DHall work (which uses `''` for QuasiQuoting stuff)

* Apply suggestions from code review

Co-authored-by: Javier Neira  <atreyu.bbb@gmail.com>

* CI: flags: post-review fxs

Co-authored-by: Anton-Latukha <anton.latukha@gmail.com>
Co-authored-by: Javier Neira  <atreyu.bbb@gmail.com>
2022-01-01 00:50:19 +00:00
Jan Hrcek
7c9b9327d8
Fix some hlint warnings (#2523)
* Fix some hlint warnings

* Revert changes in hie-compat

Co-authored-by: Anton Latukha <anton.latukha@gmail.com>
2021-12-24 21:40:17 +00:00
Pepe Iborra
d95d0eea5d
Fix hls-graph ide build with embed-files (#2485)
* Fix hls-graph build with embed-files flag

* fix hls-graph maintainer email

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-12-14 00:57:51 +00:00
Pepe Iborra
711e19cb47
Use stm-stats to reduce contention in hls-graph (#2421)
* STM stats

* Atomically stats in hls-graph

* improve contention in hls-graph

STM stats are not yet reported in the benchmark suite, so we need to run the
benchmarks manually in verbose mode to observ them (and build hls-graph with the
stm-stats Cabal flag).

  cabal build exe:ghcide ghcide-bench && cabal exec cabal run ghcide-bench -- -- -s "edit" --samples 10 --no-clean --example-module Distribution/Simple.hs --example-module Distribution/Types/Module.hs  -v

Lots of contention in `builder` and esp. `updateReverseDeps`.
`incDatabase` should not have any retries, could be a bug.
```
STM transaction statistics (2021-11-30 16:51:48.260905 UTC):
Transaction               Commits    Retries      Ratio
_anonymous_                     5          0       0.00
builder                     80886       6000       0.07
compute                     19175        141       0.01
incDatabase                    27        100       3.70
updateReverseDeps            3827        765       0.20
```
```
STM transaction statistics (2021-11-30 19:45:30.904126927 UTC):
Transaction               Commits    Retries      Ratio
_anonymous_                     1          0       0.00
builder                    606254      22569       0.04
compute                    324708      10428       0.03
incDatabase                    15          0       0.00
updateReverseDeps          259755     489285       1.88
```

```
STM transaction statistics (2021-11-30 20:21:57.968789 UTC):
Transaction               Commits    Retries      Ratio
_anonymous_                 48318          2       0.00
builder                   1108126       1276       0.00
compute                     22423        144       0.01
updateReverseDeps           65225        377       0.01
```
```
STM transaction statistics (2021-11-30 19:57:27.979412261 UTC):
Transaction               Commits    Retries      Ratio
_anonymous_                   294          0       0.00
builder                    861431       2914       0.00
compute                    324708       1573       0.00
updateReverseDeps          858100      17816       0.02
```

* added comments
2021-12-01 22:18:29 +00:00
Pepe Iborra
18633c7d1a
Lock-less hls-graph (#2411)
* Fix incomplete pattern match warning in 8.8

* lock-less hls-graph
2021-11-30 10:15:26 +00:00
Jens Petersen
d56aae4aa3
hls-graph.cabal: link to actual readme (#2404)
* hls-graph.cabal: link to actual readme

* Add readme to package

Co-authored-by: Javier Neira <atreyu.bbb@gmail.com>
2021-11-29 22:50:28 +00:00
Pepe Iborra
bd0046b708
Fix hls-graph build with embed-files flag (#2395)
* [hls-graph] fix build with embed-files flag

* bump hls-graph version number

* fix build without the flag too
2021-11-25 23:21:25 +00:00
Pepe Iborra
9639bd09e6
Show build graph statistics in ghcide-bench (#2343)
* Show build graph statistics in ghcide-bench

This adds 5 new columns to the benchmark outputs:

- buildRulesBuilt   - for which the value didn't change
- buildRulesChanged - for which the value did change
- buildRulesVisited - for which the value was not even recomputed
- buildRulesTotal   - including the rules that were not visited in the last build
- buildEdges        - total number of edges in the build graph

* Fix build

* backwards compat.
2021-11-11 18:57:25 +00:00
Pepe Iborra
2204a16bfb
Garbage collection of dirty keys (#2263) 2021-10-30 13:42:29 +01:00
Pepe Iborra
229faac11a
Generate linkables in the Eval plugin (#2295)
* [hls-graph] clean up databaseDirtySet

When I ported https://github.com/ndmitchell/shake/pull/802/files to hls-graph, I changed the encoding of the dirty set. Instead, Dirty became a constructor in the Status union. But the databaseDirtySet stayed around accidentally, leading to some confusion.

* extract GetEvalComments rule

* override NeedsCompilation rule in eval plugin to generate linkables when Evaluating

In addition, we tune the newness check of the redefined NeedsCompilation rule so that the generated linkables are not thrown away unnecessarily, as described in:

https://github.com/ndmitchell/shake/issues/794

* getLastBuildKeys

* Test that the linkables are being produced

* honor LSP_TEST_LOG_STDERR

* add comments and use custom newness check in ghcide too

* fix build

* fix 9.0 build
2021-10-25 01:38:34 +00:00
Pepe Iborra
9233be8ec7
Fix reverse dep. tracking for alwaysRerun rules (#2298)
When I ported reverse dependencies from Shake[1] I missed an important
detail. While Shake models alwaysRerun as a dependency on an actual rule
(AlwaysRerun), hls-graph models alwaysRerun by setting actionDeps to
Nothing. This is important because dependencies are not computed for
these rules, and therefore reverse dependency tracking doesn't do
anything, which breaks correctness of dirty rebuilds

This commit adds dependency tracking for alwaysRerun rules, and fixes
reverse dependency tracking. The alternative would be following the
Shake approach but I'm not sure what other implications this might have.

[1] - https://github.com/ndmitchell/shake/pull/802
2021-10-24 18:49:10 +01:00
Pepe Iborra
6c647d13f3
Preserve dirty set and add dirtiness assertion (#2279)
* do not throw away the previous dirty set

* assertion
2021-10-17 13:16:16 +01:00
Pepe Iborra
682386d1c9
Reimplement shake (continued) (#2060)
* Rewrite hls-graph to not use the Shake code

* redundant import

* Fix the bug

* add comments and format imports

* Fix another bug

* fix locking in incDatabase

* avoid calling withNumCapabilities on every build

* faster cleanup

* implement reverse deps

* --conservative-change-tracking

* Avoid grabbing the db lock when updating reverse deps

* update reverse deps asynchronously

* Profiling graph builds

* extend up profiling to record visiting steps

The main benefit of reverse dependency tracking is that we avoid unnecessary node lookups. However, these lookups were not shown in hls-graph profiles, hiding their real cost.

Concretely, if the number of lookups per build is proportional to the number of transitive dependencies of a node, which in turn is proportional to the number of transitive imports of a module, then we have an O(edges) complexity instead of an O(nodes) complexity, which is really bad for large projects.

This Diff extends the recorded data and the profiling UI to keep track
of visited nodes and to show them in a new column "Visited" of the "Rules" tab. The cost of doing this is storing an additional Int per node at runtime.

While I was editing the profiling UI, I took the chance to remove the command tabs, update the README and add some missing files

* include dirty set in profiles

* actionFork

* avoid spawning threads for simple lookups

* Fix a flaky test

* record changes to GetKnownTargets

* Readme for hls-graph

* Bump version numbers

* Drop dependency on Shake

* explain why we restart a Shake session

* clean up Internal.Database

* add a new benchmark example cabal-1module

* Fix masking and further reduce threading

* Trace aborted rule evaluations

* Fix code actions after cradle edit experiment

* Avoid spawning threads for build rules with 1 or fewer deps

* simplify a test

* hlint

* Add a test for off-editor changes

* Fix flaky tests

* fix incomplete pattern match in Tactics test suite

* Fix flaky tests

* attempt to fix tactics test suite in Windows

Co-authored-by: Neil Mitchell <ndmitchell@gmail.com>
2021-09-25 10:23:52 +00:00
Junyoung/Clare Jang
7d7c2ef4ef
Prepare 1.2.0 June release (#1912)
* Fix changelog generator

* Prepare 1.2.0

* Update plugin versions

* Fix hls plugin dependency

* Update changelog

* Fix a wrong link

* Bump other packages versions

* Revert version changes of unreleased packages

* Fix ghcide bound for hls

* Update version dependencies
2021-06-12 15:40:50 -04:00
Pepe Iborra
2ee29436fb
Technology preview: Keep track of changes to minimize rebuilds (#1862)
* Tell Shake what has changed

* Insert placeholders for missing Shake features

* disable run subset if the client doesn't support file watches

* fix another cradle test
2021-06-02 13:29:31 +01:00
Junyoung/Clare Jang
e0a464282d
Apply formats again (#1824)
* Apply formattings

* Update nix exclude range
2021-05-13 05:00:48 +00:00
Pepe Iborra
9698c16f58
Prepare ghcide release v1.3.0.0 (#1811)
* Prepare ghcide release v1.3.0.0

* refactor - move defineNoFile variants

* Refactor - move GetFilesOfInterest type and use the appropriate define

* Restore compatibility with aeson < 1.5.2

* add missing reexport
2021-05-09 18:17:24 +01:00
Neil Mitchell
dec47a31bc
Wrap the Shake functions with newtypes (#1753)
* Add a function addRule, which abstracts over addBuiltinRule

* Newtype wrap the Action, Rules and ShakeOption types

* Replace addShakeExtra with newShakeExtra

* Move the internals of hls-graph around a bit

* Expose shakeTimings and shakeAllowRedefineRules through ShakeOptions

Co-authored-by: Potato Hatsue <1793913507@qq.com>
2021-04-19 06:34:13 +00:00