greghendershott / racket-mode

Emacs major and minor modes for Racket: edit, REPL, check-syntax, debug, profile, and more.

Home Page:https://www.racket-mode.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Significant slowdowns with latest `racket-mode` version

wags-1314 opened this issue · comments

Hi, I updated my racket-mode to the latest version, and I am now seeing significant slowdowns. I am not really sure what is causing this.

((alist-get 'racket-mode package-alist)
 #s(package-desc racket-mode
		 (20231130 1652)
		 "Racket editing, REPL, and more"
		 ((emacs
		   (25 1)))
		 nil nil "/home/bhargav/.emacs.d/elpa/racket-mode-20231130.1652"
		 ((:url . "https://www.racket-mode.com/")
		  (:maintainer "Greg Hendershott")
		  (:maintainers
		   ("Greg Hendershott"))
		  (:authors
		   ("Greg Hendershott" . "racket-mode-author@greghendershott.com"))
		  (:commit . "3cadfa322d8036234a6427a8687869e6657c00fa"))
		 nil))
((emacs-version "29.1")
 (system-type gnu/linux)
 (x-gtk-use-system-tooltips t)
 (major-mode help-mode)
 (racket--el-source-dir "/home/bhargav/.emacs.d/elpa/racket-mode-20231130.1652/")
 (racket--rkt-source-dir "/home/bhargav/.emacs.d/elpa/racket-mode-20231130.1652/racket/")
 (racket-program "racket")
 (racket-command-timeout 10)
 (racket-path-from-emacs-to-racket-function UNDEFINED)
 (racket-path-from-racket-to-emacs-function UNDEFINED)
 (racket-browse-url-function racket-browse-url-using-temporary-file)
 (racket-documentation-search-location "https://docs.racket-lang.org/search/index.html?q=%s")
 (racket-xp-after-change-refresh-delay 1)
 (racket-xp-mode-lighter
  (:eval
   (racket--xp-mode-lighter)))
 (racket-xp-highlight-unused-regexp "^[^_]")
 (racket-repl-buffer-name-function nil)
 (racket-submodules-to-run
  ((test)
   (main)))
 (racket-memory-limit 2048)
 (racket-error-context medium)
 (racket-repl-history-directory "~/.emacs.d/racket-mode/")
 (racket-history-filter-regexp "\\`\\s *\\'")
 (racket-images-inline t)
 (racket-imagemagick-props nil)
 (racket-images-keep-last 100)
 (racket-images-system-viewer "display")
 (racket-pretty-print t)
 (racket-use-repl-submit-predicate nil)
 (racket-pretty-print t)
 (racket-indent-curly-as-sequence t)
 (racket-indent-sequence-depth 0)
 (racket-pretty-lambda nil)
 (racket-smart-open-bracket-enable nil)
 (racket-module-forms "\\s(\\(?:module[*+]?\\|library\\)")
 (racket-logger-config
  ((cm-accomplice . warning)
   (GC . info)
   (module-prefetch . warning)
   (optimizer . info)
   (racket/contract . error)
   (racket-mode-debugger . info)
   (sequence-specialization . info)
   (* . fatal)))
 (racket-show-functions
  (racket-show-pseudo-tooltip)))
(enabled-minor-modes
 (auto-composition-mode)
 (auto-compression-mode)
 (auto-encryption-mode)
 (auto-fill-mode)
 (auto-save-mode)
 (buffer-read-only)
 (column-number-mode)
 (context-menu-mode)
 (corfu-mode)
 (corfu-popupinfo-mode)
 (cua-mode)
 (delete-selection-mode)
 (display-battery-mode)
 (display-time-mode)
 (doom-modeline-mode)
 (electric-indent-mode)
 (electric-pair-mode)
 (file-name-shadow-mode)
 (font-lock-mode)
 (global-auto-revert-mode)
 (global-corfu-mode)
 (global-eldoc-mode)
 (global-font-lock-mode)
 (indent-tabs-mode)
 (isearch-fold-quotes-mode)
 (line-number-mode)
 (marginalia-mode)
 (menu-bar-mode)
 (mouse-wheel-mode)
 (override-global-mode)
 (pixel-scroll-precision-mode)
 (projectile-mode)
 (recentf-mode)
 (savehist-mode)
 (semantic-minor-modes-format)
 (shell-dirtrack-mode)
 (show-paren-mode)
 (tooltip-mode)
 (transient-mark-mode)
 (vertico-mode)
 (which-key-mode)
 (windmove-mode))
(disabled-minor-modes
 (abbrev-mode)
 (archive-subfile-mode)
 (auto-fill-function)
 (auto-revert-mode)
 (auto-revert-tail-mode)
 (auto-save-visited-mode)
 (avy-linum-mode)
 (blink-cursor-mode)
 (buffer-face-mode)
 (button-mode)
 (cargo-minor-mode)
 (cl-old-struct-compat-mode)
 (comint-fontify-input-mode)
 (compilation-minor-mode)
 (compilation-shell-minor-mode)
 (completion-in-region-mode)
 (consult-preview-at-point-mode)
 (cursor-face-highlight-mode)
 (dash-fontify-mode)
 (defining-kbd-macro)
 (diff-auto-refine-mode)
 (diff-minor-mode)
 (dired-hide-details-mode)
 (display-fill-column-indicator-mode)
 (display-line-numbers-mode)
 (eldoc-mode)
 (electric-layout-mode)
 (electric-quote-mode)
 (embark-collect-direct-action-minor-mode)
 (flymake-mode)
 (global-dash-fontify-mode)
 (global-display-fill-column-indicator-mode)
 (global-display-line-numbers-mode)
 (global-hl-line-mode)
 (global-hl-todo-mode)
 (global-prettify-symbols-mode)
 (global-semantic-highlight-edits-mode)
 (global-semantic-highlight-func-mode)
 (global-semantic-show-parser-state-mode)
 (global-semantic-show-unmatched-syntax-mode)
 (global-semantic-stickyfunc-mode)
 (global-visual-line-mode)
 (haskell-indentation-mode)
 (header-line-indent-mode)
 (hl-line-mode)
 (hl-todo-mode)
 (horizontal-scroll-bar-mode)
 (hs-minor-mode)
 (ibuffer-auto-mode)
 (isearch-mode)
 (jit-lock-debug-mode)
 (lock-file-mode)
 (lost-selection-mode)
 (mail-abbrevs-mode)
 (mml-mode)
 (next-error-follow-minor-mode)
 (outline-minor-mode)
 (overwrite-mode)
 (paragraph-indent-minor-mode)
 (pixel-scroll-mode)
 (prettify-symbols-mode)
 (racket-smart-open-bracket-mode)
 (racket-xp-mode)
 (read-extended-command-mode)
 (rectangle-mark-mode)
 (semantic-highlight-edits-mode)
 (semantic-highlight-func-mode)
 (semantic-mode)
 (semantic-show-parser-state-mode)
 (semantic-show-unmatched-syntax-mode)
 (semantic-stickyfunc-mode)
 (sh-electric-here-document-mode)
 (shell-highlight-undef-mode)
 (size-indication-mode)
 (tab-bar-history-mode)
 (tab-bar-mode)
 (tar-subfile-mode)
 (temp-buffer-resize-mode)
 (text-scale-mode)
 (tool-bar-mode)
 (treesit-explore-mode)
 (treesit-inspect-mode)
 (undelete-frame-mode)
 (url-handler-mode)
 (use-hard-newlines)
 (vc-dir-git-mode)
 (view-mode)
 (visible-mode)
 (visual-line-mode)
 (window-divider-mode)
 (xref-etags-mode)
 (zig-format-on-save-mode))

I'm sorry to hear that and ready to work on it.

Can you please tell me more about what kinds of things are significantly slower for you?

  • If you visit a .rkt file, is it slow to load? Is typing slow?

    If so: Are you using classic racket-mode or the experimental new racket-hash-lang-mode?

  • If you're using racket-xp-mode in the edit buffer, does disabling it make a difference? (Your details say it's disabled, but I'm just asking to be sure.)

  • Is it slow when you run a program?

    If so: Can you say more about how/when it's slow? When you first run? Is it slow to display output? Is the REPL buffer slow to accept your typing, submit expressions, and/or show you values?

  • Anything else? I'm not asking for an exhaustive inventory. In fact, the simplest example where you first notice something to be slower, would be a good place to start.

Hi

  • If you visit a .rkt file, is it slow to load? Is typing slow?
    • Yes it is slow both when loading and when typing. And no I am not using racket-hash-lang-mode.
  • If you're using racket-xp-mode in the edit buffer, does disabling it make a difference? (Your details say it's disabled, but I'm just asking to be sure.
    • I don't think I am using this minor mode.
  • Is it slow when you run a program?
    • I don't run my racket programs from Emacs.

I think the main issue I am having is the significant slowdown while typing or navigating through a racket file. Thanks for the help!

Thanks! That starts to narrow it down.

Hmm... I'm surprised. The classic racket-mode for editing files hasn't changed much recently. (Whereas racket-repl-mode for the REPL has changed significantly; I would have thought a slowdown with that would be more likely.)

But clearly something has changed. Presumably on my end in racket-mode, not in your setup.

Question: Do you recall how long ago was the previous version of Racket Mode you'd used, where it was still OK?

(If you have a rough idea, that might help me narrow down how far back to look in the history. Although since no one else has reported anything like this, yet, maybe it's quite recent.)


Even when I try my usual "torture test" file, the nearly 5000 line class-internal.rkt from Racket's source, the file loads "instantly" for me. Navigating and making changes are quick, as usual, whether near the start or end of the file.

Question: Are you seeing this slowdown even with small files? Even as tiny as say:

#lang racket/base 
42

No I am only seeing slowdown with large files. The file I am currently editing has 294 lines.

Actually I am seeing slowdown for small files too.

Do you recall roughly when your previous version of Racket Mode was from?

(One way to answer that might be: If you look in ~/.emacs.d/elpa, you might see multiple folders named racket-mode-*. What are the names?)

Also, when you are in a slow edit buffer, try M-x racket-xp-mode. Does the message say the mode was disabled? If so, is the performance better?

Do you recall roughly when your previous version of Racket Mode was from?

(One way to answer that might be: If you look in ~/.emacs.d/elpa, you might see multiple folders named racket-mode-*. What are the names?)

I only see the latest version of racket-mode (which is 20231130.1652) in the elpa directory. If I recall correctly, I started using emacs to edit racket code about a month and half ago, maybe even two months ago.

Also, when you are in a slow edit buffer, try M-x racket-xp-mode. Does the message say the mode was disabled? If so, is the performance better?

No, the mode is not enabled, and when I do enable it I don't see any improvement in performance.

Thank you for patiently answering so many questions.

You led me to improve the M-x racket-bug-report feature.

My request:

  1. Please wait for the newest version to show up on MELPA or NonGNU ELPA. I don't know which one you get it from (or even whether you know). Anyway, as I write this, neither one has updated yet.

    But by tomorrow, if you M-x package-refresh-contents, then M-x list-packages, you should see a version of the Racket Mode package later than "20231201.1736" (MELPA) or "racket-mode-1.0.20231130.115215.tar" (NonGNU ELPA).

  2. Please install that. And for belt+suspenders, please restart Emacs.

  3. Please do M-x racket-bug-report -- while you're in a racket-mode edit buffer where things are slow.

  4. Please paste that here in a new comment.


This should show me exactly which minor modes you have enabled in the slow racket-mode buffer, as well as some of the "hooks" and other variables they may have changed in that buffer.

Because most likely the slowdown is due to one of them interacting with Racket Mode. (If so, I need to know which one to make progress.)

I've already tried some modes from your old "Details" above, but so far can't reproduce any slowdown. So I'd like to get some better quality data, and try again.

Alright, will do that! Thanks for being patient with me 😄

That newer version has now flowed through to both:

  • MELPA (as 20231201.2128).
  • NonGNU ELPA (as racket-mode-1.0.20231201.162829.tar).

So regardless of which repo you get it from, M-x package-refresh-contents, then M-x list-packages should show the newer version now.

I still want to figure this out. I'll dig into the new data whenever you have a chance to...

  1. Please install latest Racket Mode. (Afterwards, please restart Emacs.)

  2. Please do M-x racket-bug-report -- while you're in a racket-mode edit buffer where things are slow.

  3. Please paste that here in a new comment.

Hi, sorry for the late response. The laptop I was using till now has stopped working, which I can't reproduce this bug anymore. racket-mode is working perfectly on my new laptop! I think we can blame this on my ailing laptop and close this issue!

I'm sorry to hear about the laptop failure; that sucks. On the other hand, congratulations on your new laptop!

This issue did result in me taking a fresh look at the bug-report data, and improving it, which hopefully will help for some other issue someday.