# \[Video\] How to Reduce Julia's Latency

**URL:** <https://discourse.julialang.org/t/video-how-to-reduce-julias-latency/100298>\
**Category:** Community\
**Created:** [June 13, 2023, 7:02pm UTC](https://discourse.julialang.org/t/video-how-to-reduce-julias-latency/100298 "2023-06-13T19:02:40Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacobusmmsmit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jacobusmmsmit/32/217669_2.png) [@jacobusmmsmit](https://discourse.julialang.org/u/jacobusmmsmit)\
**Post date:** [June 13, 2023, 7:02pm UTC](https://discourse.julialang.org/t/video-how-to-reduce-julias-latency/100298/1 "2023-06-13T19:02:41Z")

</div>

Hi everyone,

I made a video about reducing Julia’s latency after a conversation with a friend who said that they really wish all of this information was in one place.

Hence, you get this video. Possibly part one of two, where in the second I cover the packages I referenced in the outro of this one (JuliaFormatter, JET, Aqua, and Cthulhu).

[![](https://global.discourse-cdn.com/julialang/original/3X/7/8/7872bd3c135ad4361a96cef616686978e55809d6.jpeg "Minimise Julia's Latency: Revise, PrecompileTools, and PackageCompiler") ](https://www.youtube.com/watch?v=_3vJSBk0Bls)

Feedback is very welcome! I will mention, though, that while I do talk about some advanced topics, I try to not go into too much detail so if I glossed over some parts of the video or didn’t mention stuff (how PackageCompiler can do so much more or that the part that I discussed will hopefully one day be redundant) it might be because I decided not to put it in.

Thanks for watching and filling out my workflow survey if you did 😉

---

<div class="post-metadata">

**Author:** ![mrufsvold](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mrufsvold/32/31600_2.png) [@mrufsvold](https://discourse.julialang.org/u/mrufsvold)\
**Post date:** [June 13, 2023, 8:32pm UTC](https://discourse.julialang.org/t/video-how-to-reduce-julias-latency/100298/2 "2023-06-13T20:32:09Z")

</div>

This has [No Boilerplate](https://youtube.com/@NoBoilerplate) vibes, and I love it!

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [June 13, 2023, 8:34pm UTC](https://discourse.julialang.org/t/video-how-to-reduce-julias-latency/100298/3 "2023-06-13T20:34:26Z")

</div>

Very cool tutorial, taught me a few things, and I loved the drawings 😍  
A minor caveat was that the code was changing way too fast (and maybe in too small a font) for me to follow. Perhaps something to keep in mind for the next video?

I also agree that these tips and tricks should stop being part of an unspoken lore and start being explicitly documented in one place. I would love to draft a blog post for the [Julia blog](https://julialang.org/blog/), something like “Modern Julian workflows”, where I give an annotated list of what it takes to easily use, and then develop, packages. If you and my idol @jakobnissen would like to contribute, we could get this going.

---

<div class="post-metadata">

**Author:** ![jacobusmmsmit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jacobusmmsmit/32/217669_2.png) [@jacobusmmsmit](https://discourse.julialang.org/u/jacobusmmsmit)\
**Post date:** [June 13, 2023, 8:42pm UTC](https://discourse.julialang.org/t/video-how-to-reduce-julias-latency/100298/4 "2023-06-13T20:42:09Z")

</div>

> [@mrufsvold](#):
>
> This has [No Boilerplate](https://youtube.com/@NoBoilerplate) vibes, and I love it!

He was one of the two channels whose style I wanted to emulate along with [code\_report](https://www.youtube.com/watch?v=wGCWlI4A5z4). Tris got me into Rust, Conor got me into array languages, I hope I can get someone into Julia 🙂

> [@gdalle](#):
>
> I loved the drawings

\<3, I wish the whole video were done with them

> [@gdalle](#):
>
> an annotated list of what it takes to easily use, and then develop, packages

Very useful! I’d love to get involved.

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [June 13, 2023, 8:48pm UTC](https://discourse.julialang.org/t/video-how-to-reduce-julias-latency/100298/5 "2023-06-13T20:48:59Z")

</div>

> [@jacobusmmsmit](#):
>
> Very useful! I’d love to get involved.

I’ll open an issue someday soon to discuss the structure, and tag you in it

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [June 13, 2023, 10:12pm UTC](https://discourse.julialang.org/t/video-how-to-reduce-julias-latency/100298/6 "2023-06-13T22:12:52Z")

</div>

This video tutorial should be placed somewhere in the official docs! 👏

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [June 14, 2023, 6:09am UTC](https://discourse.julialang.org/t/video-how-to-reduce-julias-latency/100298/7 "2023-06-14T06:09:21Z")

</div>

> [@\[Seeking feedback\] Blog post about "Modern Julia workflows"?](https://discourse.julialang.org/t/seeking-feedback-on-a-blog-post-about-modern-julia-workflows/100324):
>
> Hi everyone, After watching a [nice video](https://discourse.julialang.org/t/video-how-to-reduce-julias-latency/100298) by @jacobusmmsmit yesterday, I sat down and thought about all the lore that experienced Julia users keep in their heads. How to write and share code properly, which packages to use and when, etc. This accumulated knowledge makes our development experience very pleasant, but it is long to acquire and beginners don’t always know where to look. The official documentation is only part of the story: best practices involve a flurry of external packages, whic…

---

<div class="post-metadata">

**Author:** ![AMJ](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amj/32/214096_2.png) [@AMJ](https://discourse.julialang.org/u/AMJ)\
**Post date:** [June 14, 2023, 7:32am UTC](https://discourse.julialang.org/t/video-how-to-reduce-julias-latency/100298/8 "2023-06-14T07:32:40Z")

</div>

Useful content, great presentation ,chad voice. 10/10.

---

<div class="post-metadata">

**Author:** ![TI36XPro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ti36xpro/32/33658_2.png) [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)\
**Post date:** [June 14, 2023, 12:02pm UTC](https://discourse.julialang.org/t/video-how-to-reduce-julias-latency/100298/9 "2023-06-14T12:02:38Z")

</div>

Great video! Really looking forward to the second one you mentioned 🙂

---

<div class="post-metadata">

**Author:** ![ShalokShalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shalokshalom/32/52462_2.png) [@ShalokShalom](https://discourse.julialang.org/u/ShalokShalom)\
**Post date:** [September 3, 2023, 8:12am UTC](https://discourse.julialang.org/t/video-how-to-reduce-julias-latency/100298/10 "2023-09-03T08:12:03Z")

</div>

I love your voice.

To the topic: Why do we adopt these techniques _optionally_, instead of making them the default workflow of everyone?

I play around with Julia in VSCode, and every time I hit the ‘run in the REPL’ button in the right top corner, it takes ages to start up.

The system feels incredible unresponsive, and that already with a few lines ☹  
Is this the experience we like to give to new users?

---

<div class="post-metadata">

**Author:** ![ShalokShalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shalokshalom/32/52462_2.png) [@ShalokShalom](https://discourse.julialang.org/u/ShalokShalom)\
**Post date:** [September 3, 2023, 8:20am UTC](https://discourse.julialang.org/t/video-how-to-reduce-julias-latency/100298/11 "2023-09-03T08:20:51Z")

</div>

Creating new packages, and utilizing Revise.jl the way you showed us, is pretty much contradicting the purpose of a REPL to me.

A REPL is meant to give me straight access to a development environment, and not something that needs complicated setup, that the vast majority of newbies will not even consider to use.

I certainly wouldn’t, and you outline one of the core issues with our REPL workflow. But the proposed solution is even worse to me, than just having to wait half an eternity for the REPL to come up, and then me having to think to close it, if there are still old functions stored.

It complicates things just further, in my opinion.

And we do have [an interpreter](https://juliadebug.github.io/JuliaInterpreter.jl/), that I would like to use as the default backend for the REPL.

No huge startup, and more suitable for small code.  
I just think adding @interpret for every execution can be skipped, and loading it in manually seems also counterintuitive to new users.

Is there a huge benefit to JIT all the code at the standard REPL instead?

---

<div class="post-metadata">

**Author:** ![mrufsvold](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mrufsvold/32/31600_2.png) [@mrufsvold](https://discourse.julialang.org/u/mrufsvold)\
**Post date:** [September 3, 2023, 11:32am UTC](https://discourse.julialang.org/t/video-how-to-reduce-julias-latency/100298/12 "2023-09-03T11:32:03Z")

</div>

The interpreter is painful slow for anything more than trivial code. The Debugger is run by the Interpreter, and you don’t have to search very far to find someone be bemoaning the Debugger’s speed. This is why the Debugger has partial compiled mode where most modules are compiled and only user code is interpretered.

Tim Holy has mentioned elsewhere (sorry don’t have a link on hand) that the interpreter could benefit from running the Julia level optimizations before running (cut out the LLVM comp time), but it hasn’t been a higher priority than getting precompilation and such. The introduction of JuliaSyntax should make it easier to trace the optimized Julia IR back to source code, so adding this should be possible now

---

<div class="post-metadata">

**Author:** ![ShalokShalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shalokshalom/32/52462_2.png) [@ShalokShalom](https://discourse.julialang.org/u/ShalokShalom)\
**Post date:** [September 3, 2023, 11:41am UTC](https://discourse.julialang.org/t/video-how-to-reduce-julias-latency/100298/13 "2023-09-03T11:41:27Z")

</div>

Thanks.

[I opened up an issue](https://github.com/JuliaDebug/JuliaInterpreter.jl/issues/588), pointing that out.

JuliaSyntax seems to have been started in 2017, but picked up steam only from 2022 forward.

Very interesting, that a project takes such a course, surely haven’t seen such a lifetime yet. 🙂

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [November 20, 2023, 9:26am UTC](https://discourse.julialang.org/t/video-how-to-reduce-julias-latency/100298/14 "2023-11-20T09:26:43Z")

</div>

> [@ShalokShalom](#):
>
> we do have [an interpreter](https://juliadebug.github.io/JuliaInterpreter.jl/), that I would like to use as the default backend for the REPL. […]
> 
> I just think adding @interpret for every execution can be skipped

FYI you can do:

```julia
julia --compile=min

```

and I think that’s exactly what you’re looking for. It can be ok for small amount of code, but yes, interpreting will be really slow, even slower than Python, since Python isn’t just an interpreter… It’s actually a compiler to its now very optimized bytecode. Though it’s been getting faster recently and Python is adding JIT.

While the package you mentioned only interprets when you use the `@interpret` macro, and running globally does always, maybe an opposite package could be made, that has `@compiled` to force compilation in the interpreter selectively… and I would like at least all package code to do that implicitly since it’s already precompiled.

With packages precompiled (when recompilation doesn’t happen; too frequently) I think Julia is (almost) good as is. You would want to use that precompiled native code (similar to C fast code in Python), and I think the above disables that.

You might want some lesser compilation (but again may force precompilation? throwing out already precompiled unnecessarily), e.g.

```julia
julia -O1

```

I think the main problem with recompilation in Julia is too much optimization, because of inlining, and e.g. `--inline=no` might help, and this is I think implicit in the above. It’s possible it would force recompilation… I would want use the precompiled code if you can, recompile as little as you could, i.e. inline less for new recompiled code, but keep the inlining you’ve already done.
