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

Fix performance of getFileExists #322

Merged
merged 17 commits into from Jan 21, 2020
Merged

Conversation

pepeiborra
Copy link
Collaborator

@pepeiborra pepeiborra commented Jan 12, 2020

This is a minimal solution that does not entirely follow the plan in #101, focusing on GetFileExists instead of GetLocatedImports.

In my experiments it solves the problem, hopefully without breaking anything else. Checked with VSCode only.

Adding tests is tricky since lsp-test does not send DidChangeWatchedFiles notifications. I'm open to suggestions on what to do.

Leveraging DidChangeWatchedFiles notifications for other purposes, e.g. in the GetModificationTime rule, is left for future PRs.

We touch the file system only the first time.
After that, we rely on the lsp client to tell us if a file is created or deleted

Fixes #101
these are the same as the default extensions allowed in the library
@cocreature cocreature self-assigned this Jan 13, 2020
@ndmitchell
Copy link
Collaborator

Nice work. To attempt to summarise the code (so I can check I am reading it right), if the IDE supports dynamic registration of files to watch, then any time we look at a file, we register a listener for it. Seems sensible and smart, and if it fixes the problem, a nice and targeted fix.

We should definitely fix lsp-test to follow the LSP spec here (maybe not immediately, but one day). It's exactly the kind of thing that is good to test!

@aherrmann-da
Copy link
Contributor

Thank you! I did a quick test run in vscode on the ghcide repository and this does greatly speed-up hover for me. On ghcide master hover takes between 0.50-0.90s to complete, and with this PR between 0.04-0.07s. In my case the reason for the slow hover on master are many file lookups in the .stack-work directory tree.

Copy link
Collaborator

@cocreature cocreature left a comment

Choose a reason for hiding this comment

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

Looks great with a bunch of comments, thank you very much!

src/Development/IDE/Core/FileExists.hs Outdated Show resolved Hide resolved
ghcide.cabal Show resolved Hide resolved
src/Development/IDE/Core/Shake.hs Outdated Show resolved Hide resolved
test/exe/Main.hs Outdated Show resolved Hide resolved
src/Development/IDE/Core/FileExists.hs Outdated Show resolved Hide resolved
src/Development/IDE/Core/FileExists.hs Show resolved Hide resolved
src/Development/IDE/Core/FileExists.hs Outdated Show resolved Hide resolved
src/Development/IDE/Core/FileExists.hs Outdated Show resolved Hide resolved
src/Development/IDE/Core/FileStore.hs Outdated Show resolved Hide resolved
src/Development/IDE/Core/FileExists.hs Outdated Show resolved Hide resolved
src/Development/IDE/Core/FileExists.hs Show resolved Hide resolved
test/exe/Main.hs Outdated Show resolved Hide resolved
src/Development/IDE/Core/FileExists.hs Show resolved Hide resolved
@mpickering
Copy link
Contributor

Thank you @pepeiborra. Once this is released I can start to advertise using ghcide on GHC's code base more.

@pepeiborra
Copy link
Collaborator Author

@cocreature is there anything else needed here?

@cocreature
Copy link
Collaborator

Should be good to go I think, I’ll do a final review tomorrow when I’m back at work.

Copy link
Collaborator

@cocreature cocreature left a comment

Choose a reason for hiding this comment

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

Looks great, with one minor comment around the call to shakeRun. Thanks a lot!

src/Development/IDE/Core/FileExists.hs Outdated Show resolved Hide resolved
src/Development/IDE/LSP/Notifications.hs Show resolved Hide resolved
@cocreature
Copy link
Collaborator

Awesome, thank you so much for working on this! Sorry for the long review process.

@cocreature cocreature merged commit 2d9314a into haskell:master Jan 21, 2020
pepeiborra added a commit to pepeiborra/ghcide that referenced this pull request Feb 1, 2020
* Improve hover performance by speeding up getFileExists

We touch the file system only the first time.
After that, we rely on the lsp client to tell us if a file is created or deleted

Fixes #101
@lukel97 lukel97 mentioned this pull request May 15, 2020
pepeiborra added a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
* Improve hover performance by speeding up getFileExists

We touch the file system only the first time.
After that, we rely on the lsp client to tell us if a file is created or deleted

Fixes haskell/ghcide#101
pepeiborra added a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
* Improve hover performance by speeding up getFileExists

We touch the file system only the first time.
After that, we rely on the lsp client to tell us if a file is created or deleted

Fixes haskell/ghcide#101
pepeiborra added a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
* Improve hover performance by speeding up getFileExists

We touch the file system only the first time.
After that, we rely on the lsp client to tell us if a file is created or deleted

Fixes haskell/ghcide#101
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.

None yet

5 participants