haskell / haskell/haskell-mode

Slow response when a simple number (e.g., 5) is trying to be resolved interactively

Open
#1,648 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Emacs Lisp
Stars
1.4k
Forks
354
Avg merge
5d 10h
Merged PRs (30d)
2

Description

I am trying a little piece of haskell code like this in a file (test.hs) using haskell-mode.

```
infixr 5 :-:
data List a = Empty | a :-: (List a) deriving (Show, Read, Eq, Ord)
```

But each time when I moved the cursor to 5 just after infixr, emacs became very slow and the CPU usage went high. Looks like haskell-mode was trying to resolve this 5 by contacting GHC interactively and finally displayed in minibuffer something like this;

5 :: Num p => p

Here is the cpu profile of emacs. (sometimes it reaches 89% etc., not only 57% shown here)

```
- haskell-process-filter 367 57%
- haskell-process-collect 367 57%
- haskell-command-exec-complete 367 57%
- # 367 57%
- # 367 57%
- eldoc-print-current-symbol-info 367 57%
- eldoc-message 367 57%
- eldoc-minibuffer-message 367 57%
- apply 367 57%
+ message 132 20%
```
I am using emacs 26.2 for windows and installed haskell-mode-20190417.309 from melpa.

And here is the configuration for it.
```
;; haskell-mode
(autoload 'haskell-mode "haskell-mode")
(autoload 'haskell-cabal "haskell-cabal")
(add-to-list 'auto-mode-alist '("\\.hs$" . haskell-mode))
;;(add-to-list 'interpreter-mode-alist '("runghc" . haskell-mode))
;;(add-to-list 'interpreter-mode-alist '("runhaskell" . haskell-mode))
;;;(setq haskell-program-name "ghci")
(add-hook 'haskell-mode-hook 'interactive-haskell-mode)
```

And this is the only external package I installed.

ghc version;
The Glorious Glasgow Haskell Compilation System, version 8.6.3

Contributor guide

Open the contributing guide

Research direction

Reproduce the slowdown with test.hs and the supplied interactive-haskell-mode configuration. Start by tracing haskell-process-filter, haskell-process-collect, haskell-command-exec-complete, and the Eldoc calls shown in the profile. Done means moving onto the numeric literal no longer drives high CPU or an unnecessary interactive GHC lookup, while normal symbol information still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
emacs, emacs-lisp, haskell
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.