-
Notifications
You must be signed in to change notification settings - Fork 97
Completions need not depend on typecheck of the current file #670
Conversation
f9968b8
to
b1be365
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
I have to admit, I’m a bit skeptical if this is a good idea. It adds a fair amount of complexity, typechecking the module returned by parsing the header seems a bit fishy and wastes resources (parsing the header is cheap, I don’t know how expensive typechecking is) and looking at the graph it seems like a 20% speedup which is great but also doesn’t seem like it will make a huge difference.
, pm_extra_src_files = [] -- src imports not allowed | ||
, pm_annotations = mempty | ||
} | ||
tm <- liftIO $ typecheckModule (IdeDefer True) env pm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs some documentation (or maybe cachedDataProducer
does). We are parsing only the header but then we also typecheck is which is at least surprising. Looking at the code the part that depends on the typechecked module is tcg_type_env
and tcg_rdr_env
. Afaik that will contain top-level definitions usually so we get less now and expect to get this from the local definitions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a comment about this in the ProduceCompletions
rule a few lines above (line 60). Does it need expanding?
To address your concerns about typechecking the module header:
I suspect the 20% improvement is more significant than it looks like. If we break down the time spent in the completions handler (including the shake session restart as this is completions after edit), I suspect it goes something like:
So a reduction of 20% in total time actually means that the completion logic is 66% more efficient, which will pay off once the other overheads go down. |
We never remove elements from the map so alter is unnecesary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, you managed to convince me that this is reasonable, thanks!
…/ghcide#670) * Faster completions * optimize withProgressVar We never remove elements from the map so alter is unnecesary * [ghcide-bench] accept ghcide options * Expand completion tests suite * hlints * completions for local foreign decls * Minor improvements for local completions * Restore completion docs in legacy code path * Compatibility with GHC < 8.8 * fix merge issue * address review feedback
…/ghcide#670) * Faster completions * optimize withProgressVar We never remove elements from the map so alter is unnecesary * [ghcide-bench] accept ghcide options * Expand completion tests suite * hlints * completions for local foreign decls * Minor improvements for local completions * Restore completion docs in legacy code path * Compatibility with GHC < 8.8 * fix merge issue * address review feedback
…/ghcide#670) * Faster completions * optimize withProgressVar We never remove elements from the map so alter is unnecesary * [ghcide-bench] accept ghcide options * Expand completion tests suite * hlints * completions for local foreign decls * Minor improvements for local completions * Restore completion docs in legacy code path * Compatibility with GHC < 8.8 * fix merge issue * address review feedback
A completion request immediately after an edit is slow because currently
ProduceCompletions
depends onTypecheck
, for very little reason.Following the plan in #655, we split
ProduceCompletions
in two rules, for local and non local (imported) completions.ModSummary
, which has early cutoff and thus do not recompute during module body edits.The speed up is visible in the completions after edit benchmark:
The rest of benchmarks stay the same:
Full benchmark data in https://github.com/pepeiborra/ghcide/tree/completions-benchmark/bench-hist
Closes #655