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

remove unnecessary FileExists dependency in GetHiFile #589

Merged
merged 3 commits into from
Jun 8, 2020

Conversation

pepeiborra
Copy link
Collaborator

@pepeiborra pepeiborra commented May 29, 2020

It is subsumed by the GetModificationTime dependency.

One less dependency per .hi file,
one less redundant file system access,
five fewer lines of code.

This does not implement all the improvements discussed in #583, it's just a minor efficiency fix.

I have not measured the performance impact either, since there is no easy-to-run standard benchmark, but I expect the impact to be very small.

@pepeiborra pepeiborra changed the title remove unnecessary FileExists dependency remove unnecessary FileExists dependency in GetHiFile May 29, 2020
Copy link
Collaborator

@ndmitchell ndmitchell left a comment

Choose a reason for hiding this comment

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

Awesome!

Minor remark that if there is no .hi file version we still check the modification time of the .hs file, even though we don't need to. I assume something else also checks that .hs file anyway, so it will be in the cache and not cost any meaningful time. Rearranging the code to avoid the second dependency if it's not needed is also a little fiddly. Up to you whether it's worth it.

@pepeiborra
Copy link
Collaborator Author

I think it's not a big deal, since the .hi file will only be missing the very first time ghcide is started on a given folder. Ever after that, the .hi file will exist.

@pepeiborra
Copy link
Collaborator Author

Benchmark BEFORE:

TOTAL hover = 2.55s
TOTAL getDefinition = 2.66s
TOTAL documentSymbols = 1.45s
TOTAL documentSymbols after edit = 2.93s
TOTAL completions after edit = 4.55s
TOTAL code actions = 3.59s
Benchmark ghcide-bench: FINISH

Benchmark AFTER:

TOTAL hover = 2.41s
TOTAL getDefinition = 2.52s
TOTAL documentSymbols = 1.44s
TOTAL documentSymbols after edit = 2.92s
TOTAL completions after edit = 4.42s
TOTAL code actions = 3.52s
Benchmark ghcide-bench: FINISH

@ndmitchell ndmitchell mentioned this pull request May 31, 2020
| otherwise = False
let isUpToDate = case (modificationTime <$> mbHieTimestamp, modificationTime srcTimestamp) of
-- If the src file is in VFS, then we know it must have been typechecked
-- by now (due to kick) and therefore its .hie file is up to date
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this true, What happens if you just opened the file? I don’t see what guarantees that the .hie file has been generated before we get here.

Copy link
Collaborator Author

@pepeiborra pepeiborra Jun 2, 2020

Choose a reason for hiding this comment

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

Hmm, you are right, we don't have a dependency on the Typecheck rule here. Looking at the rule for GetModIface, there are a couple of different scenarios depending on whether the module is a file of interest or not, etc. I'm not keen on duplicating that logic, but I think we can declare a dependency on GetModIface as a tight overapproximation of what is needed here.

It is subsumed by the GetModificationTime dependency.

One less dependency per .hi file,
one less redundant file system access,
five fewer lines of code.
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.

Thanks!

@cocreature cocreature merged commit 8f6eb2d into haskell:master Jun 8, 2020
pepeiborra added a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
…#589)

* remove unnecessary FileExists dependency

It is subsumed by the GetModificationTime dependency.

One less dependency per .hi file,
one less redundant file system access,
five fewer lines of code.

* Clarify modification time comparisons for .hi and .hie filesAddresses haskell/ghcide#591

* Fix staleness checking for .hie files (thanks @cocreature)
pepeiborra added a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
…#589)

* remove unnecessary FileExists dependency

It is subsumed by the GetModificationTime dependency.

One less dependency per .hi file,
one less redundant file system access,
five fewer lines of code.

* Clarify modification time comparisons for .hi and .hie filesAddresses haskell/ghcide#591

* Fix staleness checking for .hie files (thanks @cocreature)
pepeiborra added a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
…#589)

* remove unnecessary FileExists dependency

It is subsumed by the GetModificationTime dependency.

One less dependency per .hi file,
one less redundant file system access,
five fewer lines of code.

* Clarify modification time comparisons for .hi and .hie filesAddresses haskell/ghcide#591

* Fix staleness checking for .hie files (thanks @cocreature)
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.

3 participants