# Does Julia's speed get slower over time in REPL?

**URL:** <https://discourse.julialang.org/t/does-julias-speed-get-slower-over-time-in-repl/89066>\
**Category:** Performance\
**Created:** [October 21, 2022, 2:47pm UTC](https://discourse.julialang.org/t/does-julias-speed-get-slower-over-time-in-repl/89066 "2022-10-21T14:47:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tiZ](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tiz/32/211800_2.png) [@tiZ](https://discourse.julialang.org/u/tiZ)\
**Post date:** [October 21, 2022, 2:47pm UTC](https://discourse.julialang.org/t/does-julias-speed-get-slower-over-time-in-repl/89066/1 "2022-10-21T14:47:49Z")

</div>

When I’m on a Julia REPL that has been running for a while, I find that julia will slow down, but if I restart the REPL, the speed returns to normal.

For example, I have a function denoted f(x), that takes 15 minutes in REPL, then I execute other un-related functions like g(x), z(x)… , then a few hours pass and I execute f(x) again and it will actually take about 28 minutes, I restart a new REPL and execute the same function and this time it will only take 15 minutes again. ( The above times are after compilation).

I have enough RAM and no other tasks on my computer, I checked the CPU rate and found that when my function run on the “fresh” REPL, the CPU% could up to 80%, and run on a REPL that has been running for a few hours, it will only take 50-60% CPU.

Sorry for no actually code for demo, I don’t know if this is a common or plausible phenomenon, or if it’s just something very specific in my case. Have you ever been in a similar situation?

---

<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:** [October 21, 2022, 3:00pm UTC](https://discourse.julialang.org/t/does-julias-speed-get-slower-over-time-in-repl/89066/2 "2022-10-21T15:00:16Z")

</div>

This is very unusual. My best guess is that it’s memory/GC related, but it’s hard to know.

---

<div class="post-metadata">

**Author:** ![TheCedarPrince](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thecedarprince/32/17323_2.png) [@TheCedarPrince](https://discourse.julialang.org/u/TheCedarPrince)\
**Post date:** [October 21, 2022, 3:33pm UTC](https://discourse.julialang.org/t/does-julias-speed-get-slower-over-time-in-repl/89066/3 "2022-10-21T15:33:37Z")

</div>

I often leave my Julia REPLs running for days on end at times – I do not see this sort of behavior. Would you be willing to share about the following?

Operating System:  
Julia Version:  
Packages you use in your global environment:  
Terminal emulator:  
Any snippets of code you notice this on:

Curious if it is a regression or something specific to your set-up (my suspicion the latter). Thanks, sorry this is happening, and have a great day!

~ tcp 🌳

---

<div class="post-metadata">

**Author:** ![tiZ](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tiz/32/211800_2.png) [@tiZ](https://discourse.julialang.org/u/tiZ)\
**Post date:** [October 21, 2022, 3:51pm UTC](https://discourse.julialang.org/t/does-julias-speed-get-slower-over-time-in-repl/89066/4 "2022-10-21T15:51:45Z")

</div>

> [@TheCedarPrince](#):
>
> I often leave my Julia REPLs running for days on end at times – I do not see this sort of behavior.

Thank you very much for the tip, I now know that my question is a very special case.

My system information

```
Julia v1.7
macOS 12.1
run julia in iTerm+tmux

```

Package:

```
Clustering v0.14.3
Flux v0.13.6
GraphNeuralNetworks v0.4.5
TensorBoardLogger v0.1.12

```

There is no special setup in my julia environment. I only notice this behavior when I train neural network model with Flux. I’ll pay a little more attention to memory allocation next time.

Thank you again & have a great day!

---

<div class="post-metadata">

**Author:** ![tiZ](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tiz/32/211800_2.png) [@tiZ](https://discourse.julialang.org/u/tiZ)\
**Post date:** [October 27, 2022, 4:25am UTC](https://discourse.julialang.org/t/does-julias-speed-get-slower-over-time-in-repl/89066/5 "2022-10-27T04:25:36Z")

</div>

As an additional note, I found the answer in this post. Maybe it is related to a memory allocation/leak in Flux.

> [@Julia slowdown on long running programs with many allocations](https://discourse.julialang.org/t/julia-slowdown-on-long-running-programs-with-many-allocations/63516/6):
>
> Thanks for the responses. There are only a few places to reduce allocations further because most of them happen in the Flux model and gradient calls. I was not able to reliably replicate the exact behavior, but the issue was resolved by adding the line GC.gc(true) after each optimize\_model! call.
