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

Provide a unified (lsp-interface INTERFACE ...) pcase form #4559

Merged
merged 6 commits into from
Sep 26, 2024

Conversation

chrisbouchard
Copy link
Contributor

@chrisbouchard chrisbouchard commented Sep 23, 2024

This pull request provides a new unified pcase form (lsp-interface INTERFACE ...) to replace the old per-interface (INTERFACE ...) forms—the latter have been removed. This is a breaking change.

I've turned the old pcase-defmacros generated by lsp-interface into helper functions, which the new pcase form delegates to.

This change addresses a few issues, which are detailed in #4430. In short:

  • The existing forms aren't namespaced.
  • The lsp-mode package adds hundreds of forms, which each add several lines to pcase's generated docstring, adding up to over 1000 lines.
  • Starting in Emacs 31, the number of forms added by lsp-mode causes a noticeable slowdown when loading the interactive help for pcase.

Fixes #4430

@kiennq
Copy link
Member

kiennq commented Sep 23, 2024

  • Starting in Emacs 1.31, the number of forms added by lsp-mode causes a noticeable slowdown when loading the interactive help for pcase.

Is that Emacs 31.1 ? :D

lsp-protocol.el Outdated Show resolved Hide resolved
@dgutov
Copy link
Contributor

dgutov commented Sep 23, 2024

Starting in Emacs 1.31, the number of forms added by lsp-mode causes a noticeable slowdown when loading the interactive help for pcase

Could someone also report that slowdown to Emacs?

@chrisbouchard
Copy link
Contributor Author

chrisbouchard commented Sep 23, 2024

  • Starting in Emacs 1.31, the number of forms added by lsp-mode causes a noticeable slowdown when loading the interactive help for pcase.

Is that Emacs 31.1 ? :D

Whoops, I think just 31. Not sure where the “1.” snuck in, but I removed it. Thanks 👍

Starting in Emacs 1.31, the number of forms added by lsp-mode causes a noticeable slowdown when loading the interactive help for pcase

Could someone also report that slowdown to Emacs?

Someone definitely could! I'm not using Emacs 31 yet, so I can't speak to that issue personally. I'm mostly interested in cleaning up pcase's docstring for readability.

That said, depending what changes in Emacs 31 are triggering the slowdown, it might not actually be a bug. E.g., pcase's dynamic docstring function might have some new O(n²) feature that reasonably expects to handle a couple dozen pcase forms, not several hundred.

This commit provides a new unified pcase form (lsp-interface INTERFACE ...) to
replace the old per-interface (INTERFACE ...) forms -- the latter are now
deprecated. (Unfortunately, I don't think there's a way to mark a pcase form as
obsolete.)

I've turned the existing pcase-defmacro definition into a helper function. The
new pcase form delegates to that helper function, and the old pcase forms now
delegate to the new form.

This change addresses a few issues, which are detailed in emacs-lsp#4430. In short:

* The existing forms aren't namespaced.
* The lsp-mode package adds hundreds of forms, which each add several lines to
  pcase's generated docstring, adding up to over 1000 lines.
* Starting in Emacs 31, the number of forms added by lsp-mode causes a
  noticeable slowdown when loading the interactive help for pcase.
I've tried to summarize the behavior of the existing implementation.
I used ripgrep to search for all occurrences of `pcase`, and then checked each
to see if it was using a pattern that looked like an LSP interface name. It's
very possible I missed something, but hopefully not.
The consensus in emacs-lsp#4430 is that we're ok with making this breaking change and
communicating it in the CHANGELOG. I've replaced all uses in lsp-mode itself.
I'm an Org newb, so hopefully this is well-formatted.
Comment on lines +17 to +19
* Replace the per-interface ~(INTERFACE ...)~ pcase forms with a single,
unified ~(lsp-interface INTERFACE ...)~ form. The per-interface forms are no
longer generated. *This is a breaking change.* (See #4430.)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm definitely open to suggestions on the CHANGELOG entry.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, does the unreleased version stay 9.0.1, or should that go to 10.0.0 now?

Copy link
Member

Choose a reason for hiding this comment

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

9.0.1 is good.

@chrisbouchard chrisbouchard marked this pull request as ready for review September 24, 2024 01:04
@chrisbouchard
Copy link
Contributor Author

chrisbouchard commented Sep 24, 2024

There are two test suites failing, but they're for Emacs snapshots. Something's making the byte compiler unhappy. It looks like these are also failing in master.

@kiennq kiennq merged commit 522b1ad into emacs-lsp:master Sep 26, 2024
11 of 13 checks passed
kassick added a commit to kassick/dotfiles that referenced this pull request Oct 18, 2024
This has been reported upstream by @blahgeek (Yikai Zhao)
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=73766 and fixed in
emacs-mirror/emacs@a815bec

Along with emacs-lsp/lsp-mode#4559, this kludge should
no longer be necessary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lsp-interface generates a lot of noise in pcase documentation
4 participants