# Stray Julia processes (with high cpu usages)

**URL:** <https://discourse.julialang.org/t/stray-julia-processes-with-high-cpu-usages/33303>\
**Category:** General Usage\
**Created:** [January 13, 2020, 3:04pm UTC](https://discourse.julialang.org/t/stray-julia-processes-with-high-cpu-usages/33303 "2020-01-13T15:04:14Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [January 13, 2020, 3:04pm UTC](https://discourse.julialang.org/t/stray-julia-processes-with-high-cpu-usages/33303/1 "2020-01-13T15:04:14Z")

</div>

Post [High CPU Usage on Startup - VSCode OSX](https://discourse.julialang.org/t/high-cpu-usage-on-startup-vscode-osx/33280) triggered my post. As the link mentions, the post was about "high-cpu-usage-on-startup-vscode-osx”. I responded but didn’t want to hijack that thread so deleted my post and decided to make it a separate post.

Since Julia 1.3 I have encountered many issues with stray/high cpu usage on Julia process. It should be said that this behavior is much more often observed in the many cases I run external programs (in my case `cmdstan` and `GKSTerm`).

I wonder if the high cpu usage is confined to vscode. I see similar issues with Sublime Text and TextMate once compilation of packages start. I don’t know if in vscode’s startup sequence compilation/package indexing might be triggered.

Also, is this behavior confined to OSX? Travis test runs often time out, occasionally while it is still resolving package versions. Could that be related?

On OSX, sometimes it takes many, many minutes before it returns and often it simply never returns (although I’m not sure I ever waited overnight :-). The Activity Monitor has become a goto tool…

A third issue I have seen is that the additional Julia processes indeed seem to persist after interrupting the REPL (sometimes much later on breaking in with an error message).

Finally, in many cases when I display a plot with Plots/GR Julia simply hangs. Even the REPL stops responding. The Julia process remains running. These days I only use Plots/GR where I use `savefig()` which prevents `GKSTerm` to be activated.

I see this on 1.3 and development versions 1.4 and 1.5. I don’t think I ever saw it before Julia 1.3.

It is unclear to me if these issues are related or separate issues.

Until last week I thought it was an issue with my machine, but now I’ve quadrupled memory, disk space and cores.

Is it worth filing an issue without a real MWE?

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [January 13, 2020, 3:28pm UTC](https://discourse.julialang.org/t/stray-julia-processes-with-high-cpu-usages/33303/2 "2020-01-13T15:28:52Z")

</div>

Isn’t it called macOS now?  
This may be relevant, I mean: It may be relevant which exact version of macOS this happens.  
Other macOS users ( I am not one) may post their similar or not experience and some patterns may show up.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 13, 2020, 3:42pm UTC](https://discourse.julialang.org/t/stray-julia-processes-with-high-cpu-usages/33303/3 "2020-01-13T15:42:00Z")

</div>

> [@goedman](#):
>
> Since Julia 1.3 I have encountered many issues with stray/high cpu usage on Julia process.

It would be good to know more

1. about these processes, what exactly you mean by “stray” (eg output from `pstree`),

2. the environment variables you use for setting the number of threads/parallell

An MWE would definitely be helpful, then running it with parallelization disabled, then finally in 1.2.

> [@goedman](#):
>
> Is it worth filing an issue without a real MWE?

Possibly — comments from people could help you narrow it down. But coming up with some kind of script, even if not minimal, that reliably reproduces this on your machine would probably help a lot.

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [January 13, 2020, 5:13pm UTC](https://discourse.julialang.org/t/stray-julia-processes-with-high-cpu-usages/33303/4 "2020-01-13T17:13:30Z")

</div>

Definitely, macOS it is!

julia\> versioninfo()  
Julia Version 1.5.0-DEV.55  
Commit ade4713598 (2020-01-13 12:50 UTC)  
Platform Info:  
OS: macOS (x86\_64-apple-darwin19.3.0)  
CPU: Intel(R) Core™ i9-9880H CPU @ 2.30GHz  
WORD\_SIZE: 64  
LIBM: libopenlibm  
LLVM: libLLVM-8.0.1 (ORCJIT, skylake)  
Environment:  
JULIA\_EDITOR = subl  
JULIA\_CMDSTAN\_HOME = /Users/rob/Projects/StanSupport/cmdstan  
JULIA\_SVG\_BROWSER = Google Chrome.app  
JULIA\_SPECIALFUNCTIONS\_BUILD\_SOURCE = true  
JULIA\_PKG3\_PRECOMPILE = true

The problems have been there on Mojave as well. If in doubt if it is Julia’s under development version I always go back to the current released version of Julia (1.3.1 currently).

Without a MWE/reproducable example, the post is indeed intended to see if it is just my machine/me or if these are more common issues.

---

<div class="post-metadata">

**Author:** ![jonathanBieler](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jonathanBieler](https://discourse.julialang.org/u/jonathanBieler)\
**Post date:** [January 13, 2020, 7:37pm UTC](https://discourse.julialang.org/t/stray-julia-processes-with-high-cpu-usages/33303/5 "2020-01-13T19:37:24Z")

</div>

Look in macOS activity monitor for Julia processes that use a lot of cpu, then you can look what file they opened (in the “Open Files and Ports” tab) and check if you see something related to the language server.

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [January 13, 2020, 7:52pm UTC](https://discourse.julialang.org/t/stray-julia-processes-with-high-cpu-usages/33303/6 "2020-01-13T19:52:30Z")

</div>

Thanks Tamas,

I’ll keep on trying to come up with a reproducible example. Right now it is too much anecdotal. I’ll add another example on the StanRun issue.

And check out other suggestions on this post.

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [January 14, 2020, 3:55pm UTC](https://discourse.julialang.org/t/stray-julia-processes-with-high-cpu-usages/33303/7 "2020-01-14T15:55:38Z")

</div>

Just now it happened again. From Jonathans suggestions (PNGs below), it looks like it is in code-gen.

After several minutes the middle 2 processes went away.

This is the output of pstree:

Process group leaders are marked with ‘=’.  
➜ ~ pstree -p 65845  
-+= 00001 root /sbin/launchd  
-+= 10662 rob /System/Applications/Utilities/Terminal.app/Contents/MacOS/Term  
-+= 10664 root login -pf rob  
-+= 10665 rob -zsh  
-+= 65839 rob /Users/rob/Projects/Julia/julia/julia  
-– 65845 rob /Users/rob/Projects/Julia/julia/usr/bin/julia -Cnative  
➜ ~ pstree -p 65839  
-+= 00001 root /sbin/launchd  
-+= 10662 rob /System/Applications/Utilities/Terminal.app/Contents/MacOS/Term  
-+= 10664 root login -pf rob  
-+= 10665 rob -zsh  
-+= 65839 rob /Users/rob/Projects/Julia/julia/julia  
-– 65845 rob /Users/rob/Projects/Julia/julia/usr/bin/julia -Cnative

 ![Screen Shot 2020-01-14 at 08.41.13](https://global.discourse-cdn.com/julialang/original/3X/9/3/93006d1c3124311cbb477dbfa4e42f4bb632217a.png)

 ![Screen Shot 2020-01-14 at 08.42.10](https://global.discourse-cdn.com/julialang/original/3X/9/5/9524200df60b19d10199eb6a74ce2bef092b0fa8.png)

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [January 14, 2020, 4:11pm UTC](https://discourse.julialang.org/t/stray-julia-processes-with-high-cpu-usages/33303/8 "2020-01-14T16:11:33Z")

</div>

And it came back after 20 mins and completed the tests!

julia\> versioninfo()  
Julia Version 1.5.0-DEV.62  
Commit 756891d910 (2020-01-14 06:58 UTC)  
Platform Info:  
OS: macOS (x86\_64-apple-darwin19.3.0)  
CPU: Intel(R) Core™ i9-9880H CPU @ 2.30GHz  
WORD\_SIZE: 64  
LIBM: libopenlibm  
LLVM: libLLVM-8.0.1 (ORCJIT, skylake)  
Environment:  
JULIA\_EDITOR = subl  
JULIA\_CMDSTAN\_HOME = /Users/rob/Projects/StanSupport/cmdstan  
JULIA\_SVG\_BROWSER = Google Chrome.app  
JULIA\_SPECIALFUNCTIONS\_BUILD\_SOURCE = true  
JULIA\_PKG3\_PRECOMPILE = true

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 15, 2020, 8:32am UTC](https://discourse.julialang.org/t/stray-julia-processes-with-high-cpu-usages/33303/9 "2020-01-15T08:32:58Z")

</div>

So this is a LanguageServer/VS Code issue?

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [January 15, 2020, 5:26pm UTC](https://discourse.julialang.org/t/stray-julia-processes-with-high-cpu-usages/33303/10 "2020-01-15T17:26:55Z")

</div>

Maybe. I’m not sure what the open port to julia-codegen really means.

But, as often is the case, just asking a question helped. For a long time (7 years already!?!) I used a few definitions like below (importing Base.\* of course):

```julia
  function *(c1::Cmd, c2::Cmd)
    res = deepcopy(c1)
    for i in 1:length(c2.exec)
      push!(res.exec, c2.exec[i])
    end
    res
  end

  function *(c1::Cmd, sa::Array{String, 1})
    res = deepcopy(c1)
    for i in 1:length(sa)
      push!(res.exec, sa[i])
    end
    res
  end

  function *(c1::Cmd, s::String)
    res = deepcopy(c1)
    push!(res.exec, s)
    res
  end

```

and this I think is no longer possible in Julia 1.3 and higher. No error is shown but compilations don’t (ever?) return.

I used these to build a run CmdStan in all of StanJulia/… and in JagsJulia/Jags.jl. I have removed them from StanJulia but not from Jags yet.

Both on my system and on Travis this has made a huge difference for StanJulia.

Jags might provide a reproducible case in fact. Developing Jags.jl should install Jags and `] test Jags` hangs my system, currently on Julia Version 1.5.0-DEV.70 (2020-01-15) on macOS Catalina.

It would be of great help if you could confirm my suspicion. Luckily the work around is easy, using cmd interpolations instead to `*`.

As always, thanks for your (and others) help!

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [January 15, 2020, 8:10pm UTC](https://discourse.julialang.org/t/stray-julia-processes-with-high-cpu-usages/33303/11 "2020-01-15T20:10:21Z")

</div>

And yes, it did come back again in the end, after about 30 mins. The tests then run until it misses Random and sits quiet for a really long time. The second pause is ok, that’s my error, must have started between Julia 1.2 and 1.3.

Just now I did rebuild Julia and was able to reproduce the ‘issue’ (very long pre-compile time). After my next build of Julia dev I will try without above constructs in master.

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [January 18, 2020, 9:30pm UTC](https://discourse.julialang.org/t/stray-julia-processes-with-high-cpu-usages/33303/12 "2020-01-18T21:30:42Z")

</div>

Just for completeness, below a case where Julia did not come back for several hours.

 ![Screen Shot 2020-01-18 at 12.45.10](https://global.discourse-cdn.com/julialang/original/3X/6/b/6b2984f77f6050a4585f4d7641f90e21c8b950cc.png)

Julia Version 1.5.0-DEV.104  
Commit 372a7a726d (2020-01-18 18:35 UTC)  
Platform Info:  
OS: macOS (x86\_64-apple-darwin19.3.0)  
CPU: Intel(R) Core™ i9-9880H CPU @ 2.30GHz  
WORD\_SIZE: 64  
LIBM: libopenlibm  
LLVM: libLLVM-8.0.1 (ORCJIT, skylake)  
Environment:  
JULIA\_EDITOR = subl  
JULIA\_CMDSTAN\_HOME = /Users/rob/Projects/StanSupport/cmdstan  
JULIA\_SVG\_BROWSER = Google Chrome.app  
JULIA\_SPECIALFUNCTIONS\_BUILD\_SOURCE = true  
JULIA\_PKG3\_PRECOMPILE = true

---

<div class="post-metadata">

**Author:** ![longemen3000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/longemen3000/32/7298_2.png) [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Post date:** [January 18, 2020, 9:55pm UTC](https://discourse.julialang.org/t/stray-julia-processes-with-high-cpu-usages/33303/13 "2020-01-18T21:55:22Z")

</div>

i will put my two cents and bet that it is the language server of the VSCode Plugin. it takes a lot of time to index the packages (variable, but over half an hour), and when its doing that, it takes a lot of resources.

> [@VS Code extension v0.13.0 release candidate](https://discourse.julialang.org/t/vs-code-extension-v0-13-0-release-candidate/32360/28):
>
> Not stored on disc means that it has yet to been indexed and cached by SymbolServer. This is only done once per package version, so the long wait is only done once. Once it has been cached it will be fine. If it completes, it says “store set”. There does seem to be a fairly large slowdown in performance in the latest VSCode extension.

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [January 18, 2020, 11:26pm UTC](https://discourse.julialang.org/t/stray-julia-processes-with-high-cpu-usages/33303/14 "2020-01-18T23:26:29Z")

</div>

I do have VS Code on my system but have not used it for several months. I use Sublime Text.

My next step is to work for a few days just on J1.3.1 two see if that reduces these very long (re-)compiles from admittedly `dev`-ed, but unchanged packages.

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [January 21, 2020, 6:13pm UTC](https://discourse.julialang.org/t/stray-julia-processes-with-high-cpu-usages/33303/15 "2020-01-21T18:13:32Z")

</div>

Not sure at all if my interpretation of the `Open files and ports` is correct, but when Julia appears to `hang` very often the last file open points to the repl\_history.jl. Not in the cases where it came back after 10 or 15 minutes though.

 ![Screen Shot 2020-01-21 at 07.50.57](https://global.discourse-cdn.com/julialang/original/3X/1/0/10ad28959902f537007202c40f9d458fec60c63b.png)

 ![Screen Shot 2020-01-21 at 10.36.45](https://global.discourse-cdn.com/julialang/original/3X/2/e/2e8ed640ac98c5b0fbc9d94abcdbcb3e140cf046.png)

---

<div class="post-metadata">

**Author:** ![Junars](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/junars/32/16094_2.png) [@Junars](https://discourse.julialang.org/u/Junars)\
**Post date:** [July 5, 2020, 11:36am UTC](https://discourse.julialang.org/t/stray-julia-processes-with-high-cpu-usages/33303/16 "2020-07-05T11:36:03Z")

</div>

Every time it causes high CPU usage, I close it, the process seems to be endless. So, I should wait for it to end?

---

<div class="post-metadata">

**Author:** ![stochastic\_guy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stochastic_guy/32/9877_2.png) [@stochastic\_guy](https://discourse.julialang.org/u/stochastic_guy)\
**Post date:** [January 18, 2022, 9:08pm UTC](https://discourse.julialang.org/t/stray-julia-processes-with-high-cpu-usages/33303/17 "2022-01-18T21:08:27Z")

</div>

Any updates on this issue. I notice similar Julia stray processes on M1 Mac with Julia 1.7
