# Package load speed: Windows vs Linux

**URL:** https://discourse.julialang.org/t/package-load-speed-windows-vs-linux/93039
**Category:** Performance
**Tags:** windows, startup, ttfx
**Created:** [January 16, 2023, 7:04pm UTC](https://discourse.julialang.org/t/package-load-speed-windows-vs-linux/93039 "2023-01-16T19:04:48Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![tfiers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tfiers/32/32427_2.png) [@tfiers](https://discourse.julialang.org/u/tfiers)
#### Post date: [January 16, 2023, 7:04pm UTC](https://discourse.julialang.org/t/package-load-speed-windows-vs-linux/93039/1 "2023-01-16T19:04:48Z")

</div>

I have a feeling that Julia package import times are significantly faster on Linux than on Windows.  
See e.g. [this thread](https://github.com/PainterQubits/Unitful.jl/issues/595#issuecomment-1353337925) where:

- @giordano’s seven-year-old Linux laptop loads Unitful in 0.44 seconds
- my two-year-old Windows laptop (i7, 8-core, SSD) loads Unitful in 1.38 seconds (3x as slow)

(Both measurements were made in a fresh tmp env, in a `--startup-file=no` session. My Julia version was 1.8.1)

Quoting Mosè Giordano in that same thread, “I/O is pretty terrible on Windows”

(For an explanation of why Windows I/O is slower than Linux, see e.g. these two reddit threads: [one](https://www.reddit.com/r/linux/comments/w7no0p/why_are_most_operations_in_windows_much_slower/), [two](https://www.reddit.com/r/linux/comments/9gwphj/why_does_linux_seem_to_be_an_order_of_magnitude/). The second links to ["I Contribute to the Windows Kernel. We Are Slower Than Other Operating Systems. Here Is Why."](http://blog.zorinaq.com/i-contribute-to-the-windows-kernel-we-are-slower-than-other-oper/))

* * *

With native code caching in upcoming Julia versions, these import times will increase further (see left column in image below)

So, I’m a bit worried. (Especially because, I presume, most core devs use Linux. And thus, loading more small files might feel like a relatively cheap operation – correct me if I’m wrong).

Should I switch to Linux? I’ll miss PowerPoint.  
Should Julia package loading do something different on Windows? (A shot in the dark: maybe bundling many small cache files together in one big tarball would help, to pay the I/O tax only once, instead of many times)

  

* * *

Nice plot by @msjgriffiths ([source](https://twitter.com/msjgriffiths/status/1608173872062386176)) of Tim Holy’s data [in #47184](https://github.com/JuliaLang/julia/pull/47184#issuecomment-1363986440):

 ![image](https://global.discourse-cdn.com/julialang/original/3X/1/d/1d468c7536124a40fc8e9e193737cbddba6c79eb.jpeg)

---

<div class="post-metadata">

### Author: ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)
#### Post date: [January 16, 2023, 7:32pm UTC](https://discourse.julialang.org/t/package-load-speed-windows-vs-linux/93039/2 "2023-01-16T19:32:07Z")

</div>

Other things being possibly true, one must also not forget that Windows Julia binaries are built on Unix instead of being _natively_ Windows. I’ve seen many times dlls built with the MinGW tool-chain being 2, 3, 5, ~10 times bigger than those built with VisualStudio.

There was a time when Octave had a native Windows built. The main VS dll was ~20 MB and 200 MB in the official cross-compiling distribution. Unfortunately it’s easy to point fingers and forget this _little_ detail.

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [January 16, 2023, 7:44pm UTC](https://discourse.julialang.org/t/package-load-speed-windows-vs-linux/93039/3 "2023-01-16T19:44:05Z")

</div>

> [@joa-quim](#):
>
> one must also not forget that Windows Julia binaries are built on Unix instead of being _natively_ Windows.

That’s not true. And even if that were true, it doesn’t address the fact I/O on Windows is intrinsically slow also outside of the Julia world.

---

<div class="post-metadata">

### Author: ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)
#### Post date: [January 16, 2023, 7:47pm UTC](https://discourse.julialang.org/t/package-load-speed-windows-vs-linux/93039/4 "2023-01-16T19:47:50Z")

</div>

> [@giordano](#):
>
> That’s not true.

What part is not true?

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [January 16, 2023, 7:51pm UTC](https://discourse.julialang.org/t/package-load-speed-windows-vs-linux/93039/5 "2023-01-16T19:51:06Z")

</div>

The part that I quoted: the official Julia release is compiled natively on Windows.

---

<div class="post-metadata">

### Author: ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)
#### Post date: [January 16, 2023, 7:53pm UTC](https://discourse.julialang.org/t/package-load-speed-windows-vs-linux/93039/6 "2023-01-16T19:53:31Z")

</div>

With VisualStudio?

---

<div class="post-metadata">

### Author: ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)
#### Post date: [January 16, 2023, 7:53pm UTC](https://discourse.julialang.org/t/package-load-speed-windows-vs-linux/93039/7 "2023-01-16T19:53:58Z")

</div>

I think you’re getting off-topic.

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [January 16, 2023, 8:11pm UTC](https://discourse.julialang.org/t/package-load-speed-windows-vs-linux/93039/8 "2023-01-16T20:11:03Z")

</div>

> [@tfiers](#):
>
> With native code caching in upcoming Julia versions, these import times will increase further (see left column in image below)

That might make the difference between Linux and Windows smaller, not bigger. It seems to me likely that the change in loading time will be OS-independent.

Also, get the profiler out and start measuring things before speculating too much about performance numbers. If it actually is I/O that is slow, then which part of I/O? Once that is known, then there can be discussions about how to fix it.

---

<div class="post-metadata">

### Author: ![tfiers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tfiers/32/32427_2.png) [@tfiers](https://discourse.julialang.org/u/tfiers)
#### Post date: [January 16, 2023, 8:11pm UTC](https://discourse.julialang.org/t/package-load-speed-windows-vs-linux/93039/9 "2023-01-16T20:11:57Z")

</div>

> [@kristoffer.carlsson](#):
>
> get the profiler out and start measuring things before speculating too much about performance numbers. If it actually is I/O that is slow, then which part of I/O?

I’d love to but am not well acquainted with low-level systems software. How’d you go about that?

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [January 16, 2023, 8:13pm UTC](https://discourse.julialang.org/t/package-load-speed-windows-vs-linux/93039/10 "2023-01-16T20:13:43Z")

</div>

You can learn :).

As a reference see the productive discussion in [Loading is 10x slower under Windows than WSL on the same machine · Issue #40570 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/40570) which lead to e.g. [prevent doing excessive file system checks in require calls by KristofferC · Pull Request #40890 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/40890).

---

<div class="post-metadata">

### Author: ![tfiers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tfiers/32/32427_2.png) [@tfiers](https://discourse.julialang.org/u/tfiers)
#### Post date: [January 16, 2023, 8:16pm UTC](https://discourse.julialang.org/t/package-load-speed-windows-vs-linux/93039/11 "2023-01-16T20:16:22Z")

</div>

Thanks for the pointers, hadn’t seen those yet (I only searched the discourse for keywords)

---

<div class="post-metadata">

### Author: ![tfiers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tfiers/32/32427_2.png) [@tfiers](https://discourse.julialang.org/u/tfiers)
#### Post date: [January 22, 2023, 9:24pm UTC](https://discourse.julialang.org/t/package-load-speed-windows-vs-linux/93039/12 "2023-01-22T21:24:00Z")

</div>

Just for reference and anyone stumbling upon this:  
I am now doing my Julia work in WSL2 (windows subsystem for linux), and…

~~I’m absolutely baffled. Package load times are amazingly fast, in comparison.  
So much so that I feel WSL should be the official recommendation for Julia on Windows.~~

_Edit_: see post below. Seems like most of this speedup was due to something else, like upgrading Julia from 1.8 to 1.9 , and not due to WSL

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [January 22, 2023, 9:41pm UTC](https://discourse.julialang.org/t/package-load-speed-windows-vs-linux/93039/13 "2023-01-22T21:41:35Z")

</div>

Can you give some more concrete examples? I’m interested in looking at this but e.g. [Windows is slower than WSL2 in loading GR, Preferences, Julia 1.9.0-beta2 - #5 by kristoffer.carlsson](https://discourse.julialang.org/t/windows-is-slower-than-wsl2-in-loading-gr-preferences-julia-1-9-0-beta2/92623/5) failed to repro for me.

---

<div class="post-metadata">

### Author: ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)
#### Post date: [January 22, 2023, 9:57pm UTC](https://discourse.julialang.org/t/package-load-speed-windows-vs-linux/93039/14 "2023-01-22T21:57:05Z")

</div>

My general sense is that Windows performance may get less attention than Linux performance. It seems much more likely that I’m the first one to recognize an issue on Windows. This could be merely because many of the developers and users of Julia tend to primarily work on Linux.

The exchange that Kristoffer linked above revealed an issue that was affecting Windows users more than Linux users. `stat` is regularly used when accessing a file since it determines basic information such as does the file exist and if you have permission to access it. In particular, a basic `stat` operation on Linux is about 100x faster than its Windows analog (~100 nanoseconds versus ~10 microseconds). At a small scale a few microseconds is not noticeable, but over many file accesses this becomes noticeable on Windows before Linux. In that case, Julia was accessing the same file repeatedly. On Linux the cost for doing so is negligible but the cost is noticeable on Windows.

Fortunately due to Windows Subsystem for Linux 2, this is quite easy to evaluate now. Simply profile the operations in Windows and WSL2 and report the output of the following.

```julia
using Profile
Profile.clear()
@profile begin
   <task that is slower on Windows than WSL2>
end
Profile.print(; C = true, format = :flat, sortedby = :count, mincount = 4)

```

The difference between Windows and WSL2 does point to something having gone awry in the Win32 API or NTFS file system rather than a fundamental issue in the Windows NT microkernel.

---

<div class="post-metadata">

### Author: ![tfiers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tfiers/32/32427_2.png) [@tfiers](https://discourse.julialang.org/u/tfiers)
#### Post date: [January 22, 2023, 10:29pm UTC](https://discourse.julialang.org/t/package-load-speed-windows-vs-linux/93039/15 "2023-01-22T22:29:59Z")

</div>

Ok I tried a quick benchmark (not yet with any `Profile`ing); and it seems WSL is not actually that much faster here.  
Seems like the big package load time speedup I observed was rather due to upgrading from Julia 1.8 to 1.9. My apologies 😅

In this test I use a kind-of-messy collection of re-exports and tools, [GitHub - tfiers/MyToolbox.jl: To import at the start of an interactive session. Re-exports useful libraries and defines miscellaneous utility functions that don't fit in a proper package.](https://github.com/tfiers/MyToolbox.jl)

Protocol:

```julia
mkdir timetest
julia --startup-file=no --project=timetest -e "using Pkg; pkg\"add https://github.com/tfiers/MyToolbox.jl#11629da\"; @time using MyToolbox"

```

(warning, this takes a while in a fresh julia install: 152 packages will be precompiled. In parallel, so your cpu is occupied for a bit)

Windows:

```julia
  4.416453 seconds (2.47 M allocations: 161.221 MiB, 3.22% gc time, 0.59% compilation time)

```

WSL2:

```julia
  3.383194 seconds (2.35 M allocations: 154.908 MiB, 5.67% gc time, 0.75% compilation time)

```

These times very a bit from run to run, but WSL is consistently about one second faster

Julia 1.9.0-beta3 on both.

* * *

I don’t have the previous Julia version installed anymore, but this import used to take 40+ seconds until just a day ago (in an IJulia notebook, on Julia 1.8, with other packages in the same environment too). Hence my enthousiasm in the above post

---

<div class="post-metadata">

### Author: ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)
#### Post date: [January 22, 2023, 10:45pm UTC](https://discourse.julialang.org/t/package-load-speed-windows-vs-linux/93039/16 "2023-01-22T22:45:54Z")

</div>

The experience from IJulia is sometimes strange. I notice that sometimes precompilation caching does not work sometimes with IJulia, but it does pick up the cache once I precompiled with the plain Julia REPL first.

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [January 23, 2023, 8:58am UTC](https://discourse.julialang.org/t/package-load-speed-windows-vs-linux/93039/17 "2023-01-23T08:58:29Z")

</div>

Not to derail this thread too much, but how do you actually use Julia in WSL2? I set up WSL2 and installed Julia, but given that WSL2 is just a headless Ubuntu by default it can’t plot, there’s no GUI applications like VSCode, no browser to run Pluto in etc. I looked into setting things up such that GUI applications can be run but it all seemed pretty cumbersome.

---

<div class="post-metadata">

### Author: ![albheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albheim/32/34660_2.png) [@albheim](https://discourse.julialang.org/u/albheim)
#### Post date: [January 23, 2023, 9:41am UTC](https://discourse.julialang.org/t/package-load-speed-windows-vs-linux/93039/18 "2023-01-23T09:41:24Z")

</div>

Seems like you need either win 11 or win 10 build 19044+, I recently got a high enough version on my old win 10 and tried it out, worked quite nicely

> **[Run Linux GUI apps with WSL](https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps)**
>
> Learn how WSL support running Linux GUI apps.

I also have a vague feeling I have been able to run servers on localhost and access them from windows, but not sure about this and not at that computer right now. A quick google seems to claim this is how windows/wsl should work

> <https://superuser.com/questions/1131874/how-to-access-localhost-of-linux-subsystem-from-windows>

but apparently wsl2 lost that ability. Though it seems to be coming back if you have a recent enough build

> **[WSL2 Now Supports Localhost Connections From Windows 10 Apps](https://www.bleepingcomputer.com/news/security/wsl2-now-supports-localhost-connections-from-windows-10-apps/)**
>
> With the release of the Windows 10 Insider build 18945, the Windows Subsystem for Linux version 2 now supports the ability for Windows 10 applications to connect to WSL2 apps via localhost.

---

<div class="post-metadata">

### Author: ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)
#### Post date: [January 23, 2023, 9:47am UTC](https://discourse.julialang.org/t/package-load-speed-windows-vs-linux/93039/19 "2023-01-23T09:47:21Z")

</div>

> [@nilshg](#):
>
> there’s no GUI applications like VSCode

You can use vs code and wsl together [Developing in the Windows Subsystem for Linux with Visual Studio Code](https://code.visualstudio.com/docs/remote/wsl)

This has been around for several years.

---

<div class="post-metadata">

### Author: ![tfiers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tfiers/32/32427_2.png) [@tfiers](https://discourse.julialang.org/u/tfiers)
#### Post date: [January 23, 2023, 10:05am UTC](https://discourse.julialang.org/t/package-load-speed-windows-vs-linux/93039/20 "2023-01-23T10:05:44Z")

</div>

VS Code remote indeed, and for plotting: jupyter notebooks (I use Mambaforge conda), with IJulia.

The notebook server is available just on localhost on Windows, through some magic  
I.e. I can confirm what @albheim researched (I have win11 and WSL2)

[Next page](https://discourse.julialang.org/t/package-load-speed-windows-vs-linux/93039.md?page=2)
