# Debugging extremely slow

**URL:** https://discourse.julialang.org/t/debugging-extremely-slow/53801
**Category:** Tooling
**Tags:** question
**Created:** [January 22, 2021, 7:18pm UTC](https://discourse.julialang.org/t/debugging-extremely-slow/53801 "2021-01-22T19:18:00Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![PrintRind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/printrind/32/20433_2.png) [@PrintRind](https://discourse.julialang.org/u/PrintRind)
#### Post date: [January 22, 2021, 7:18pm UTC](https://discourse.julialang.org/t/debugging-extremely-slow/53801/1 "2021-01-22T19:18:00Z")

</div>

I’m currently trying to make the switch from Matlab to Julia 1.5.3. I am currently working with Atom/Juno (Atom 1.54.0, uber-juno 0.3.0) because of it’s similarity to the the Matlab editor. While I like many things in Julia, I’m having a really hard time debugging my code. Coming from Matlab, I am used to set breakpoints to see the definition of variables inside loops, functions etc. quickly.

In Juno, evaluating steps in the debugger takes AGES (I am speaking of minutes!) unless the function is very simple. I’ve been searching for solutions for a quite long time now and my current understanding is that this is to be expected(?) I would be grateful for a brief reply from an expert. Are there any good alternatives to Atom/Juno?

Thanks!

---

<div class="post-metadata">

### Author: ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)
#### Post date: [January 22, 2021, 7:52pm UTC](https://discourse.julialang.org/t/debugging-extremely-slow/53801/2 "2021-01-22T19:52:49Z")

</div>

Julia’s interpreted mode is known to be pretty slow - speeding it up is a work in progress. The best way to quickly drop into a function’s scope is [Infiltrator.jl](https://github.com/JuliaDebug/Infiltrator.jl), or you can use [Exfiltrator.jl](https://github.com/antoine-levitt/Exfiltrator.jl) to send variables in deeply-nested scopes back to the global scope. Both should be just as fast as any other JIT-compiled method.

---

<div class="post-metadata">

### Author: ![PrintRind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/printrind/32/20433_2.png) [@PrintRind](https://discourse.julialang.org/u/PrintRind)
#### Post date: [January 23, 2021, 7:28am UTC](https://discourse.julialang.org/t/debugging-extremely-slow/53801/3 "2021-01-23T07:28:11Z")

</div>

Thanks a lot! I’ve tried “Infiltrator.jl” and it seems to be a valuable tool.

---

<div class="post-metadata">

### Author: ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)
#### Post date: [January 23, 2021, 8:32am UTC](https://discourse.julialang.org/t/debugging-extremely-slow/53801/4 "2021-01-23T08:32:49Z")

</div>

Believe it or not, I suspect that one of Matlab’s advantages here is that all the performance-sensitive stuff is written in C and their debugger doesn’t step into it. So their debugger only lets you look at surface level logic, but the flip side is that it doesn’t really hurt performance. Conversely, the Julia debugger goes down to every single operation, and that just kills performance.

As a first cut you can try

```julia
julia> using JuliaInterpreter

julia> push!(JuliaInterpreter.compiled_modules, Base)
Set{Module} with 2 elements:
  Base.Threads
  Base

```

and see if it helps. (That will cause it to skip debugging for every method defined in Base.) Or, if you _really_ want to exclude everything in Base, do

```julia
julia> using MethodAnalysis

julia> visit(Base) do item
           isa(item, Module) && push!(JuliaInterpreter.compiled_modules, item)
           true
       end

```

which will block every submodule of Base too. You might need to add some stdlibs too.

---

<div class="post-metadata">

### Author: ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)
#### Post date: [January 23, 2021, 9:06am UTC](https://discourse.julialang.org/t/debugging-extremely-slow/53801/5 "2021-01-23T09:06:42Z")

</div>

> [@PrintRind](#):
>
> Are there any good alternatives to Atom/Juno?

It might be worth switching to [VSCode](https://www.julia-vscode.org/) since development on Atom is being phased out. Although switching probably won’t solve your debugging issues, VSCode seems to be more responsive overall. Both IDEs have similar features and setups.

---

<div class="post-metadata">

### Author: ![PrintRind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/printrind/32/20433_2.png) [@PrintRind](https://discourse.julialang.org/u/PrintRind)
#### Post date: [January 23, 2021, 11:07am UTC](https://discourse.julialang.org/t/debugging-extremely-slow/53801/6 "2021-01-23T11:07:20Z")

</div>

Hi Tim.

Thanks for this great advice.  
Your first suggestion shortened the degugger to reach my breakpoint from “forever” to about 40 seconds.  
Your second suggestion shortened it further to a second or so. Now it really feels like Matlab: I can step quickly through all the lines and see how variables develop.

I would really appreciate if there would be a simple button “Debugger for dummies” 😉 or something similar in a Julia editor that would allow for this kind of “superficial” inspection.

I’ve noticed that the Juno debugger seems to deliver many more details on the code than Matlab’s. But frankly speaking, I am not an IT specialist and don’t understand code at this level anyway.

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [January 23, 2021, 1:04pm UTC](https://discourse.julialang.org/t/debugging-extremely-slow/53801/7 "2021-01-23T13:04:27Z")

</div>

Perhaps these two options could be added to Juno or vscode to improve the user experience? Would that be possible?

---

<div class="post-metadata">

### Author: ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)
#### Post date: [January 23, 2021, 4:02pm UTC](https://discourse.julialang.org/t/debugging-extremely-slow/53801/8 "2021-01-23T16:02:37Z")

</div>

In my opinion, there should be 4 levels of exclusion. The default should be to compile everything except deved packages and code outside packages. The next should be to compile everything in base and stdlib. The third should be to compile only base, and the 4th should be to compile nothing.

The reason to default to compiling everything is that new users mostly won’t be trying to debug external packages and are the least likely to know how to use startup.jl to change the behavior.

---

<div class="post-metadata">

### Author: ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)
#### Post date: [January 23, 2021, 4:24pm UTC](https://discourse.julialang.org/t/debugging-extremely-slow/53801/9 "2021-01-23T16:24:26Z")

</div>

The biggest problem with that approach is that it breaks when higher order functions are used:

```julia
julia> f(x) = 2x
f (generic function with 1 method)

julia> breakpoint(f)
f

julia> outer(arr) = map(f, arr)
outer (generic function with 1 method)

julia> @run outer([1,2,3]) # this should break when `f` is called, but doesn't
3-element Array{Int64,1}:
 2
 4
 6

```

---

<div class="post-metadata">

### Author: ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)
#### Post date: [February 24, 2021, 9:13am UTC](https://discourse.julialang.org/t/debugging-extremely-slow/53801/10 "2021-02-24T09:13:01Z")

</div>

To resolve this, I propose that instead we should have: _compile everything in Base except a predefined list of higher order functions_.  
It’s not perfect, but i think it would be relatively easy and get as a lot of the way there.  
I have been told that this is feasible.

---

<div class="post-metadata">

### Author: ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)
#### Post date: [February 24, 2021, 10:05am UTC](https://discourse.julialang.org/t/debugging-extremely-slow/53801/11 "2021-02-24T10:05:46Z")

</div>

Ha, I totally forgot we talked about that idea. Will add a “compile all in module except for” functionality to [UI for setting compiled funcs/mods by pfitzseb · Pull Request #1888 · julia-vscode/julia-vscode · GitHub](https://github.com/julia-vscode/julia-vscode/pull/1888).

---

<div class="post-metadata">

### Author: ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)
#### Post date: [February 25, 2021, 1:50pm UTC](https://discourse.julialang.org/t/debugging-extremely-slow/53801/12 "2021-02-25T13:50:29Z")

</div>

I have a semi-automatically generated whitelist [here](https://github.com/julia-vscode/julia-vscode/pull/1888/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519R916-R953) and would be happy to add missing higher order functions in Base (or in stdlibs, actually) to that.

---

<div class="post-metadata">

### Author: ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)
#### Post date: [February 25, 2021, 2:27pm UTC](https://discourse.julialang.org/t/debugging-extremely-slow/53801/13 "2021-02-25T14:27:20Z")

</div>

The list is called `debuggerDefaultCompiled`, is it a list of function that _will_ or _will not_ be compiled by default?

---

<div class="post-metadata">

### Author: ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)
#### Post date: [February 25, 2021, 2:28pm UTC](https://discourse.julialang.org/t/debugging-extremely-slow/53801/14 "2021-02-25T14:28:16Z")

</div>

Yes 🙂 (depends on whether a function is prefixed with a `-` or not).

---

<div class="post-metadata">

### Author: ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)
#### Post date: [February 25, 2021, 2:32pm UTC](https://discourse.julialang.org/t/debugging-extremely-slow/53801/15 "2021-02-25T14:32:10Z")

</div>

Ah, thanks for clarifying 🙂 I was thinking about list comprehensions

```julia
julia> Meta.@lower [a for a in 1:2]
:($(Expr(:thunk, CodeInfo(
    @ none within `top-level scope'
1 ─ %1 = 1:2
│ %2 = Base.Generator(Base.identity, %1)
│ %3 = Base.collect(%2)
└── return %3
))))

```

is it `Generator` that needs to be added?  
EDIT: Oxinabox already pointed that out 👍

---

<div class="post-metadata">

### Author: ![spinystellate](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@spinystellate](https://discourse.julialang.org/u/spinystellate)
#### Post date: [March 14, 2022, 1:07pm UTC](https://discourse.julialang.org/t/debugging-extremely-slow/53801/16 "2022-03-14T13:07:02Z")

</div>

I’m sorry for reviving an old thread, but I am in the same situation as OP (new to Julia from Matlab) and struggling to debug my code. I am running Julia v1.7 in VS Code. I just implemented the 2 suggestions by tim.holy, but the debugger is still too slow to be useful. Are there any other suggestions of things I could try? I will explore Infiltrator as a next step, but was hoping for a debugger that looks and feels like the one in Matlab…

---

<div class="post-metadata">

### Author: ![GeekTea](https://avatars.discourse-cdn.com/v4/letter/g/9d8465/32.png) [@GeekTea](https://discourse.julialang.org/u/GeekTea)
#### Post date: [March 23, 2022, 11:56pm UTC](https://discourse.julialang.org/t/debugging-extremely-slow/53801/17 "2022-03-23T23:56:57Z")

</div>

You’re not alone. I’m a long time Matlab user but would love to give Julia a go, it has lots of promise and the open source community appeals to me.  
I was worried about learning a new syntax but that is proving not too difficult. The insane debug times are putting me off though; its not just a little frustrating it’s nearly unworkeable for my workflow anyway. Also in VSCode.  
I’m sure most users would be concerened mainly about debugging their own code at hand rather than absolutely everything. So I do like the previously mentioned ideas of that being default behaviour.

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [March 24, 2022, 1:22am UTC](https://discourse.julialang.org/t/debugging-extremely-slow/53801/18 "2022-03-24T01:22:17Z")

</div>

Debugging in vscode should work fine if configured correctly. Have a look at the end of this discussion to understand which settings are needed: [https://github.com/julia-vscode/julia-vscode/issues/2465](https://github.com/julia-vscode/julia-vscode/issues/2465)

---

<div class="post-metadata">

### Author: ![GeekTea](https://avatars.discourse-cdn.com/v4/letter/g/9d8465/32.png) [@GeekTea](https://discourse.julialang.org/u/GeekTea)
#### Post date: [March 24, 2022, 1:07pm UTC](https://discourse.julialang.org/t/debugging-extremely-slow/53801/19 "2022-03-24T13:07:39Z")

</div>

Thank you Uwe, I will take a look at your link!

---

<div class="post-metadata">

### Author: ![fmvin](https://avatars.discourse-cdn.com/v4/letter/f/b38774/32.png) [@fmvin](https://discourse.julialang.org/u/fmvin)
#### Post date: [April 10, 2023, 5:11pm UTC](https://discourse.julialang.org/t/debugging-extremely-slow/53801/20 "2023-04-10T17:11:03Z")

</div>

One year has passed since the last activity from this topic. But this debugging problem is not resolved yet.  
For test purposes a small piece of code with GLMakie plotting was created. First start of the app takes about 30 sec (with sysimage) and it could be tolerable somehow. But each time a debugger takes about 30-40 sec to start and it’s terribly slow. Code development becomes extremely slow and unpleasant.  
I followed all recommendations in this topic and similar topics regarding GLMakie but with no significant positive effect.  
The configuration is Julia 1.9.0-rc2 or 1.8.5, VScode with julia plugin v1.45.1, Win10 and all packages are uptodate.

Could you please advise me on the next tries?

[Next page](https://discourse.julialang.org/t/debugging-extremely-slow/53801.md?page=2)
