Skip to content

fix: enable compression for large messages#15

Merged
robsimmons merged 1 commit into
leanprover:nixosfrom
jcreedcmu:nixos-jcreed-compress
Jul 16, 2026
Merged

fix: enable compression for large messages#15
robsimmons merged 1 commit into
leanprover:nixosfrom
jcreedcmu:nixos-jcreed-compress

Conversation

@jcreedcmu

Copy link
Copy Markdown
Collaborator

Full completions when mathlib is imported can be on the order of 200k items, on the order of 20-40MB jsonrpc responses. Because these are on the same websocket connection as $/lean/fileProgress, we will block on transferring the completions response before communicating to the user that elaboration has finished successfully. This sometimes leads to reportedly 10-30s user-visible latency between finishing typing and waiting for the yellow spinner in the infoview to resolve.

In practice, completions appear to be compressed by a factor of 8-9x by the deflate algorithm supported by websockets. We expect this should improve user-facing (non-completion) responsiveness when large completions are in flight, as other factors such as JSON.parse or toString are measured as negligible (well under 100ms) for the same payload. It may also improve end-to-end completion responsiveness itself, but probably at most only by a factor of about 2x according to experiments.

Full completions when mathlib is imported can be on the order of 200k
items, on the order of 20-40MB jsonrpc responses. Because these are on
the same websocket connection as `$/lean/fileProgress`, we will block
on transferring the completions response before communicating to the
user that elaboration has finished successfully. This sometimes leads
to reportedly 10-30s user-visible latency between finishing typing and
waiting for the yellow spinner in the infoview to resolve.

In practice, completions appear to be compressed by a factor of 8-9x
by the deflate algorithm supported by websockets. We expect this
should improve user-facing (non-completion) responsiveness when large
completions are in flight, as other factors such as JSON.parse or
toString are measured as negligible (well under 100ms) for the same
payload. It may also improve end-to-end completion responsiveness
itself, but probably at most only by a factor of about 2x according to
experiments.
@robsimmons
robsimmons self-requested a review July 16, 2026 17:36

@robsimmons robsimmons left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What a wonky set of defaults (w.r.t threshold/{server,client}Takeover). Hopefully this will help - it might make sense to see if you can get similar performance wobbles on Jon's server which would indicate we should upstream this.

@jcreedcmu

Copy link
Copy Markdown
Collaborator Author

Oh yeah perhaps I should make a parallel upstream PR; I was thinking of prioritizing empirical testing by bhavik, but there's no reason not to seek feedback from both concurrently.

@jcreedcmu

Copy link
Copy Markdown
Collaborator Author

I'm pushing a revert just to see if the null PR still exhibits the same test failures reliably.

@jcreedcmu
jcreedcmu force-pushed the nixos-jcreed-compress branch from e90d98a to add3dba Compare July 16, 2026 18:02
@jcreedcmu

Copy link
Copy Markdown
Collaborator Author

The revert had the same test failure. I conclude therefore that the failure is not related to this PR.

@robsimmons
robsimmons merged commit c1a95f9 into leanprover:nixos Jul 16, 2026
4 of 14 checks passed
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

Successfully merging this pull request may close these issues.

2 participants