Skip to content

Improve performance of clojure-ts-align - #145

Merged
bbatsov merged 1 commit into
clojure-emacs:mainfrom
rrudakov:feat/speedup-align-forms
Aug 23, 2026
Merged

Improve performance of clojure-ts-align#145
bbatsov merged 1 commit into
clojure-emacs:mainfrom
rrudakov:feat/speedup-align-forms

Conversation

@rrudakov

Copy link
Copy Markdown
Contributor

Cache semantic indentation rules for a single clojure-ts-align run to avoid lookup for every repeating symbol.

Context: I noticed that clojure-ts-align can be quite slow when aligning very large expressions (i.e. large EDN system configurations or large integration test functions). clojure-ts-mode performs lookup for an indentation rule for every symbol, with CIDER connected it also involves nREPL communication.

I've been using this improved version for a very long time and haven't noticed any downsides.


Before submitting a PR mark the checkboxes for the items you've done (if you
think a checkbox does not apply, then leave it unchecked):

  • The commits are consistent with our contribution guidelines.
  • You've added tests (if possible) to cover your change(s). Bugfix, indentation, and font-lock tests are extremely important!
  • You've run M-x checkdoc and fixed any warnings in the code you've written.
  • You've updated the changelog (if adding/changing user-visible functionality).
  • You've updated the readme (if adding/changing user-visible functionality).

Thanks!

@bbatsov bbatsov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry for sitting on this so long, it slipped past me when you opened it.

I stubbed clojure-ts-get-indent-function with a 1ms delay to stand in for an nREPL round-trip and aligned a 200-clause cond: 406 lookups down to 3, 0.64s down to 0.13s. Good win.

Heads up that main moved under you and this conflicts now. Comments inline, nothing blocking.

Comment thread clojure-ts-mode.el
Comment thread clojure-ts-mode.el Outdated
Comment thread test/clojure-ts-mode-indentation-test.el
@rrudakov
rrudakov force-pushed the feat/speedup-align-forms branch 2 times, most recently from ad3e408 to afdda6e Compare August 22, 2026 20:05
Cache semantic indentation rules for a single clojure-ts-align run to avoid
lookup for every repeating symbol.
@rrudakov
rrudakov force-pushed the feat/speedup-align-forms branch from afdda6e to 7755702 Compare August 22, 2026 20:06
@rrudakov
rrudakov requested a review from bbatsov August 22, 2026 20:08
@bbatsov
bbatsov merged commit 2bce67a into clojure-emacs:main Aug 23, 2026
4 of 5 checks passed
@rrudakov
rrudakov deleted the feat/speedup-align-forms branch August 29, 2026 12:16
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