# Slow julia-mode on Windows 10

**URL:** https://discourse.julialang.org/t/slow-julia-mode-on-windows-10/44182
**Category:** Tooling
**Created:** [August 3, 2020, 10:48am UTC](https://discourse.julialang.org/t/slow-julia-mode-on-windows-10/44182 "2020-08-03T10:48:24Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)
#### Post date: [August 3, 2020, 10:48am UTC](https://discourse.julialang.org/t/slow-julia-mode-on-windows-10/44182/1 "2020-08-03T10:48:24Z")

</div>

I observe intermittent sluggish behavior when using Emacs’ julia-mode in two different Windows 10 computers and Emacs 26.3: an arrow key move takes sometimes between 1 and 5 seconds. Non julia-modes are instead working fine. Has anybody experienced the same?

---

<div class="post-metadata">

### Author: ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)
#### Post date: [August 3, 2020, 12:04pm UTC](https://discourse.julialang.org/t/slow-julia-mode-on-windows-10/44182/2 "2020-08-03T12:04:56Z")

</div>

Could you try using the emacs profiler to see where time is spent? I have some suspicions of what the issue might be, but data is better.

---

<div class="post-metadata">

### Author: ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)
#### Post date: [August 3, 2020, 1:30pm UTC](https://discourse.julialang.org/t/slow-julia-mode-on-windows-10/44182/3 "2020-08-03T13:30:41Z")

</div>

This is what `M-x profiler-report` gives:

```julia
- linum-update-current 115,987,976 58%
 - linum-update 115,982,696 58%
  - mapc 115,978,472 58%
   - linum-update-window 115,907,744 58%
    - window-end 2,644,090 1%
     - jit-lock-function 43,831 0%
      - jit-lock-fontify-now 43,482 0%
       - jit-lock--run-functions 42,426 0%
        - run-hook-wrapped 42,426 0%
         + #<compiled 0x22d9df1> 42,426 0%
      linum--face-width 324,096 0%
      count-lines 31,178 0%
      line-number-at-pos 6,336 0%
      * 888 0%
    get-buffer-window-list 4,224 0%
- command-execute 67,205,914 34%
 - call-interactively 67,201,690 34%
  - funcall-interactively 49,753,158 25%
   - next-line 37,497,102 18%
    - line-move 37,484,430 18%
     - line-move-partial 35,857,490 18%
      + window-screen-lines 92,920 0%
      + default-line-height 76,008 0%
      + window-inside-pixel-edges 12,672 0%
        pos-visible-in-window-p 11,135 0%
     + line-move-visual 1,217,060 0%
     + default-line-height 77,080 0%
     + window-inside-pixel-edges 17,952 0%
    + called-interactively-p 7,392 0%
   + execute-extended-command 9,456,080 4%
   + previous-line 2,452,252 1%
   + profiler-report-toggle-entry 143,184 0%
     right-char 116,720 0%
   + scroll-up-command 50,116 0%
     left-char 37,704 0%
  + byte-code 17,448,532 8%
+ redisplay_internal (C function) 14,310,167 7%
+ timer-event-handler 32,736 0%
+ ... 10,316 0%
+ undo-auto--add-boundary 5,280 0%
+ global-font-lock-mode-check-buffers 1,056 0%
+ blink-cursor-end 1,056 0%

```

---

<div class="post-metadata">

### Author: ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)
#### Post date: [August 3, 2020, 2:14pm UTC](https://discourse.julialang.org/t/slow-julia-mode-on-windows-10/44182/4 "2020-08-03T14:14:30Z")

</div>

I don’t see anything in that trace specific to `julia-mode`. Did you experience the slowdown while taking it? You could try `elp-instrument-package` instead.

I do see that some cpu time is taken by `linum-mode` which is known to cause slowdowns with large files. Are you aware of `display-line-numbers-mode` in emacs 26+? It should be much more performant.

---

<div class="post-metadata">

### Author: ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)
#### Post date: [August 3, 2020, 6:52pm UTC](https://discourse.julialang.org/t/slow-julia-mode-on-windows-10/44182/5 "2020-08-03T18:52:44Z")

</div>

I followed your suggestion and set `global-display-line-numbers-mode`. The problem persists and I can trigger it if I scroll up and down a few times: the results below are when the slowdown happens.

```julia
- command-execute 338,079,599 97%
 - call-interactively 338,079,599 97%
  - funcall-interactively 330,285,543 95%
   - previous-line 314,753,104 91%
    - line-move 314,753,104 91%
     + line-move-visual 298,623,462 86%
       line-pixel-height 19,530 0%
   + scroll-down-command 7,516,324 2%
   + execute-extended-command 5,882,311 1%
   + kill-buffer 1,151,906 0%
   + delete-other-windows 874,913 0%
   + profiler-report-toggle-entry 64,336 0%
   + next-line 41,304 0%
     right-char 1,024 0%
     switch-to-buffer 321 0%
  + byte-code 7,739,564 2%
  + completing-read-default 54,492 0%
+ redisplay_internal (C function) 7,057,386 2%
+ timer-event-handler 25,344 0%
  ... 0 0%

```

I am not sure what functions to profile with `elp-instrument-package`. I tried `julia-` but the list of `elp-results` was empty.

---

<div class="post-metadata">

### Author: ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)
#### Post date: [August 3, 2020, 7:47pm UTC](https://discourse.julialang.org/t/slow-julia-mode-on-windows-10/44182/6 "2020-08-03T19:47:38Z")

</div>

> [@mzaffalon](#):
>
> I am not sure what functions to profile with `elp-instrument-package` . I tried `julia-` but the list of `elp-results` was empty.

That just means that it didn’t find any `julia-` functions called. Which doesn’t necessarily mean that it’s not julia-mode’s fault.

Is it all julia files where you see this behavior or only certain ones? Do you see the same behavior if you edit the file with a different major mode, e.g. `python-mode`? I just can’t imagine a scenario where `julia-mode` slowed down `line-move-visual` which is what’s showing a the root of most of your cpu time in the trace above. Maybe `visual-line-mode` is the problem?

---

<div class="post-metadata">

### Author: ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)
#### Post date: [August 4, 2020, 6:09am UTC](https://discourse.julialang.org/t/slow-julia-mode-on-windows-10/44182/7 "2020-08-04T06:09:10Z")

</div>

Thank you for following up.

I saw the behavior on different Julia file.

When I tried this morning, `python-mode`, `julia-mode` and `latex-mode` were all working fine. Yesterday on the other hand, I could trigger the sluggishness (for `julia-mode`) after a few seconds of usage. I will try again later.

---

<div class="post-metadata">

### Author: ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)
#### Post date: [August 4, 2020, 8:45am UTC](https://discourse.julialang.org/t/slow-julia-mode-on-windows-10/44182/8 "2020-08-04T08:45:26Z")

</div>

It is definitely associated with `julia-mode`. The slow-down goes away if I load a python script or a LaTeX file and reappears once I switch back to the Julia code.

---

<div class="post-metadata">

### Author: ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)
#### Post date: [August 4, 2020, 11:42am UTC](https://discourse.julialang.org/t/slow-julia-mode-on-windows-10/44182/9 "2020-08-04T11:42:27Z")

</div>

Could you try using `python-mode` on the julia file where you experience sluggishness?

---

<div class="post-metadata">

### Author: ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)
#### Post date: [August 5, 2020, 7:09am UTC](https://discourse.julialang.org/t/slow-julia-mode-on-windows-10/44182/10 "2020-08-05T07:09:55Z")

</div>

It is definitely the `julia-mode`. I move the cursor around until the Emacs becomes sluggish, I `M-x python-mode` and if I wait a couple of seconds without doing anything, the cursor is again responsive. I switch back to `julia-mode` and the cursor barely moves.

---

<div class="post-metadata">

### Author: ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)
#### Post date: [August 5, 2020, 8:37pm UTC](https://discourse.julialang.org/t/slow-julia-mode-on-windows-10/44182/11 "2020-08-05T20:37:46Z")

</div>

Since you’re just moving around in the file (not editing), my best guess is that it’s related to font-locking (my first guess would have been that it’s related to indentation). Could you try first changing `syntax-propertize-function` and seeing if sluggishness remains and then try `font-lock-defaults`? If either of those fixes the problem then we at least have a place to start looking. If not, then I’m stumped as to what’s going on.

---

<div class="post-metadata">

### Author: ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)
#### Post date: [August 5, 2020, 8:41pm UTC](https://discourse.julialang.org/t/slow-julia-mode-on-windows-10/44182/12 "2020-08-05T20:41:09Z")

</div>

If you can, it would also be good to check that you can reproduce this slowdown with `emacs -q` and manually loading `julia-mode`–to make sure this isn’t an interaction between julia-mode and another package.

---

<div class="post-metadata">

### Author: ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)
#### Post date: [March 11, 2021, 4:51pm UTC](https://discourse.julialang.org/t/slow-julia-mode-on-windows-10/44182/13 "2021-03-11T16:51:00Z")

</div>

For once the symbol `∈` slows down Emacs. If I replace it with `in`, scrolling is again fast.

```julia
function f(log::Dict, index::Int)
    # Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam
    # commodo urna in ultrices efficitur. Maecenas non mi ac ante
    # pharetra rutrum sagittis ac dolor. Suspendisse ante augue,
    # fermentum ac scelerisque sit amet, porttitor eget ante. Vivamus
    # id nulla eget nunc molestie cursus nec quis lorem.
    index ∈ keys(log)

    # Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam
    # commodo urna in ultrices efficitur. Maecenas non mi ac ante
    # pharetra rutrum sagittis ac dolor. Suspendisse ante augue,
    # fermentum ac scelerisque sit amet, porttitor eget ante. Vivamus
    # id nulla eget nunc molestie cursus nec quis lorem.
end

```

Emacs 26.3, julia-mode 20200917.713
