Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Switch back to bytecode #873

Merged
merged 5 commits into from
Oct 19, 2020
Merged

Switch back to bytecode #873

merged 5 commits into from
Oct 19, 2020

Conversation

wz1000
Copy link
Collaborator

@wz1000 wz1000 commented Oct 17, 2020

I think this is the best option left now.

There are a couple of feasible alternatives I can think of:

  1. Use a hybrid strategy, using object code the first time we compile and bytecode all subsequent times. This should be easy to implement after this PR, it would require just a two line change in getLinkableType. We can also generate object code (but not use it) on save. This will hopefully result in faster startup and less memory usage at boot, but as files are changed, memory usage will quickly climb to and surpass the bytecode only strategy (since the object code will be loaded in and we can't unload it).

  2. I think it should be possible to serialize core to iface files, taking hints from ezyang/ghc@13615ca. For this scheme to be backwards compatible with older GHCs, I think could be possible to sneak in the Core Bindings as [IfaceRule] in the mi_rules field of the ModIface, giving the rules some special names that could be filtered out by ghcide and used to reconstruct the ModGuts

Fixes #854, #672 , #858

@wz1000
Copy link
Collaborator Author

wz1000 commented Oct 17, 2020

Benchmarks aren't too bad!

(From CI)

haskell-lsp-types-0.22.0.0   upstream   hover                        True      100       16.962058416         0.0                  0.8305386510000001    4.181997899999999e-2    0.8780088930000001   182176552      13786903360
haskell-lsp-types-0.22.0.0   HEAD       hover                        True      100       9.394807919          0.0                  0.316495781           4.5747614e-2            0.368137091          195544496      6058657208
haskell-lsp-types-0.22.0.0   upstream   edit                         True      100       17.619571603         0.0                  91.19241291200002     4.628883900000001e-2    91.247870358         242977288      94466896136
haskell-lsp-types-0.22.0.0   HEAD       edit                         True      100       9.450252650000001    0.0                  84.74284567200002     4.2988895000000006e-2   84.794505705         288995760      79560108168
haskell-lsp-types-0.22.0.0   upstream   getDefinition                True      100       17.464248046         0.0                  0.12073135799999998   5.9497715e-2            0.186164149          183945800      13780545936
haskell-lsp-types-0.22.0.0   HEAD       getDefinition                True      100       9.614923776000001    0.0                  0.12543128999999997   5.3537691000000005e-2   0.184674571          204424880      6054098424
haskell-lsp-types-0.22.0.0   upstream   hover after edit             True      100       16.917623560000003   0.0                  13.103849260999993    53.881535882            66.992606733         242468232      69760893512
haskell-lsp-types-0.22.0.0   HEAD       hover after edit             True      100       9.499022147          0.0                  5.409612720000008     54.003901043            59.420993991         269167496      55055010552
haskell-lsp-types-0.22.0.0   upstream   completions after edit       True      100       17.021458348         0.0                  32.49573733100001     36.659056484000004      69.174757375         244475512      86475278192
haskell-lsp-types-0.22.0.0   HEAD       completions after edit       True      100       9.656699881          0.0                  24.130707007999998    37.34349355000002       61.491058453         257467128      71557453640
haskell-lsp-types-0.22.0.0   upstream   code actions                 True      100       16.933771813         13.082935746         1.782118793           3.951253300000002e-2    1.8294510320000001   252392088      27345981784
haskell-lsp-types-0.22.0.0   HEAD       code actions                 True      100       9.351906150000001    5.7861885200000005   1.172493083           4.366150299999999e-2    1.2259577700000002   279317040      12429762664
haskell-lsp-types-0.22.0.0   upstream   code actions after edit      True      100       17.482058035         0.0                  117.21471565700001    1.7246926859999994      118.95512668500001   303327720      125856314640
haskell-lsp-types-0.22.0.0   HEAD       code actions after edit      True      100       9.666414923000001    0.0                  110.907798942         0.436028621             111.358387543        328776216      111840298664
haskell-lsp-types-0.22.0.0   upstream   documentSymbols after edit   True      100       147.315276616        0.0                  1.0619371570000002    0.583950261             1.65804982           185073400      16787461176
haskell-lsp-types-0.22.0.0   HEAD       documentSymbols after edit   True      100       9.331877910000001    0.0                  0.838720596           5.982076042000003       6.835655439000001    252244248      13444260672

@pepeiborra
Copy link
Collaborator

pepeiborra commented Oct 17, 2020

Kudos @wz1000 I hope the community will appreciate all your work on getting TH to work properly with ghcide. I will review tomorrow.

Copy link
Collaborator

@pepeiborra pepeiborra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/Development/IDE/Core/Compile.hs Show resolved Hide resolved
@@ -290,6 +303,12 @@ instance Hashable GetModIface
instance NFData GetModIface
instance Binary GetModIface

data GetModIfaceWithoutLinkable = GetModIfaceWithoutLinkable
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want GetModIface and GetModIfaceWithoutLinkable,
or GetModIface and GetModIfaceWithLinkable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, this way is more consistent with GetModIface and GetModIfaceWithoutTimestamps. If you feel otherwise, we can change it.

The only place where it makes a difference is when defining new Rules (since it can save recomputation if the linkable changed but the iface hash remained the same). If it is just used with runIdeAction or something, then there shouldn't be any difference.

src/Development/IDE/Core/Rules.hs Show resolved Hide resolved
src/Development/IDE/Core/Rules.hs Show resolved Hide resolved
src/Development/IDE/Core/Shake.hs Outdated Show resolved Hide resolved
@wz1000 wz1000 merged commit 71c88dc into haskell:master Oct 19, 2020
pepeiborra pushed a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
* Switch back to bytecode

* return a HomeModInfo even if we can't generate a linkable

* set target to HscNothing

* add rule for GetModIfaceWithoutLinkable

* use IdeGlobal for compiled linkables
pepeiborra pushed a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
* Switch back to bytecode

* return a HomeModInfo even if we can't generate a linkable

* set target to HscNothing

* add rule for GetModIfaceWithoutLinkable

* use IdeGlobal for compiled linkables
pepeiborra pushed a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
* Switch back to bytecode

* return a HomeModInfo even if we can't generate a linkable

* set target to HscNothing

* add rule for GetModIfaceWithoutLinkable

* use IdeGlobal for compiled linkables
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Link error when modifying TH
2 participants