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

RFC - ShakeSession and shakeRunGently (2) #555

Closed
wants to merge 3 commits into from

Conversation

pepeiborra
Copy link
Collaborator

@pepeiborra pepeiborra commented May 9, 2020

This Request For Comments builds on top of #554 addressing the performance of completions.

shakeRunGently enabled massive speed ups for:

  • Hover
  • Code Actions

But not for completions, which are usually requested immediately after a file
edit, which in turn triggers a non gentle shakeRun, which resets the
ShakeSession, and therefore getCompletions finds a cold ShakeSession and is slow
as a result.

The obvious question then, is why not make every shakeRun a gentle one?
The non gentle shakeRun disappears, and with it the ability to cancel Shake actions
Is cancelling actions an important feature?

  • We can now run multiple actions concurrently, so it is no longer necessary to
    wait until the current action finishes.
    This removes the need for cancellation in user triggered actions, like hover, code
    actions and completions.
  • Thanks to recent changes in ghcide, most actions have become cheap enough.
    I wonder if this is enough to remove the need for cancelling typechecks

pepeiborra added 3 commits May 8, 2020 20:17
Currently we start a new Shake session for every interaction with the Shake
database, including type checking, hovers, code actions, completions, etc.
Since only one Shake session can ever exist, we abort the active session if any
in order to execute the new command in a responsive manner.

This is suboptimal in many, many ways:

- A hover in module M aborts the typechecking of module M, only to start over!
- Read-only commands (hover, code action, completion) need to typecheck all the
  modules! (or rather, ask Shake to check that the typechecks are current)
- There is no way to run non-interfering commands concurrently

This is an experiment inspired by the 'ShakeQueue' of @mpickering, and
the follow-up discussion in mpickering#7

We introduce the concept of the 'ShakeSession' as part of the IDE state.
The 'ShakeSession' is initialized by a call to 'shakeRun', and survives until
the next call to 'shakeRun'. It is important that the session is restarted as
soon as the filesystem changes, to ensure that the database is current.

The 'ShakeSession' enables a new command 'shakeRunGently', which appends work to
the existing 'ShakeSession'. This command can be called in parallel without any
restriction.
shakeRunGently enabled massive speed ups for:

- Hover
- Code Actions

But not for completions, which are usually requested immediately after a file
edit, which in turn triggers a non gentle shakeRun, which resets the
ShakeSession, and therefore getCompletions finds a cold ShakeSession and is slow
as a result.

The obvious question then, is why not make every shakeRun a gentle one?
The non gentle shakeRun disappears, and with it the ability to cancel Shake actions
Is cancelling actions an important feature?

- We can now run multiple actions concurrently, so it is no longer necessary to
  wait until the current action finishes.
  This removes the need for cancellation in user triggered actions, like hover, code
  actions and completions.
- Thanks to recent changes in ghcide, most actions have become cheap enough.
  I wonder if this is enough to remove the need for aborting typechecks
@pepeiborra
Copy link
Collaborator Author

pepeiborra commented May 9, 2020

This is a failed attempt. The 'ShakeSession' does not see filesystem edits unless it is restarted to update the Shake database.

@pepeiborra pepeiborra closed this May 9, 2020
@pepeiborra pepeiborra mentioned this pull request May 9, 2020
1 task
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.

1 participant