Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lean becomes unresponsive due to many concurrent getSnapshotData requests #51

Open
Aaron1011 opened this issue Oct 12, 2024 · 2 comments

Comments

@Aaron1011
Copy link

Currently, paperproof calls the getSnapshotData lean function every time the cursor is moved:

const proofTreeResponse = await vscodeRequest(log, "getSnapshotData", client, uri, tdp, { pos: tdp.position });

For large theorems, this can be very expensive (~5 seconds on my machine). However, paperproof never cancels inflight requests ($/cancelRequest), which means that quickly switching between lines can cause a large number of concurrent getSnapshotData requests. When viewing a complex theorem, this can easily lead to ~90% cpu usage, while also preventing other requests from being serviced (e.g. vscode-lean updating the infoview)

@lakesare
Copy link
Collaborator

lakesare commented Oct 12, 2024

I can reproduce this.
This also happens with the paperproof panel closed, the only way to make the InfoView fast again is to disable the Paperproof extension.

Thanks for the analysis of the problem, I think you're spot on, and this should certainly be fixed.

TODOs:

  • don't send the fetchLeanData() request at all when the Paperproof panel is closed (shared.webviewPanel === null)
    [easy fix that at least makes paperproof not interfere with the InfoView speed when the Paperproof panel is closed]
  • send the RPC call cancellation request ($/cancelRequest) whenever token.isCancellationRequested is true

@lakesare
Copy link
Collaborator

lakesare commented Oct 13, 2024

I deployed the fix for the first task, now Paperproof won't affect the InfoView performance when the Paperproof panel is closed.

As per the second task - I understood there is no need to perform the expensive getSnapshotData() operation at all (and therefore no need to cancel it), it only needs to be called once per theorem, and reiterated if the user changed something in the theorem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants