# First call latency in distributed code

**URL:** https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917
**Category:** Performance
**Tags:** distributed, latency
**Created:** [October 18, 2022, 3:07pm UTC](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917 "2022-10-18T15:07:32Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![shce](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@shce](https://discourse.julialang.org/u/shce)
#### Post date: [October 19, 2022, 11:51am UTC](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917/21 "2022-10-19T11:51:04Z")

</div>

I run `julia -p 2 --trace-compile=custom_precompile.jl myFile.jl`, where `myFile.jl` runs a simple example. Then, when I try to generate the sysimage `create_sysimage([:JuMP, :GLPK], sysimage_path="JuMPGLPKSysimage_CustomPrecompile.so", precompile_execution_file="custom_precompile.jl")`

I get the following error:

```julia
**[ Info:** ===== Start precompile execution =====

**ERROR:** LoadError: UndefVarError: Distributed not defined
[...]

```

It might be not possible to generate a sysimage using a distributed code as `precompile_execution_file`.

---

<div class="post-metadata">

### Author: ![jmair](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmair/32/35117_2.png) [@jmair](https://discourse.julialang.org/u/jmair)
#### Post date: [October 19, 2022, 12:46pm UTC](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917/22 "2022-10-19T12:46:57Z")

</div>

It is possible, but you probably need to include `Distributed` in the sysimage too along with the other packages.

---

<div class="post-metadata">

### Author: ![shce](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@shce](https://discourse.julialang.org/u/shce)
#### Post date: [October 19, 2022, 1:46pm UTC](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917/23 "2022-10-19T13:46:16Z")

</div>

Sadly, the same happens if I include `Distributed`

```julia
julia> create_sysimage([:JuMP, :GLPK, :Distributed], sysimage_path="JuMPGLPKSysimage_CustomPrecompile.so", precompile_execution_file="custom_precompile.jl")
[ Info: ===== Start precompile execution =====
ERROR: LoadError: UndefVarError: Distributed not defined
[...]

```

Can you think of an alternative?

Thanks in advance

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [October 19, 2022, 1:48pm UTC](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917/24 "2022-10-19T13:48:02Z")

</div>

using them and use actualy pkg instead of Symbol?

---

<div class="post-metadata">

### Author: ![shce](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@shce](https://discourse.julialang.org/u/shce)
#### Post date: [October 19, 2022, 2:20pm UTC](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917/25 "2022-10-19T14:20:00Z")

</div>

I’m afraid I don’t fully understand your suggestion.

---

<div class="post-metadata">

### Author: ![jmair](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmair/32/35117_2.png) [@jmair](https://discourse.julialang.org/u/jmair)
#### Post date: [October 19, 2022, 5:58pm UTC](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917/26 "2022-10-19T17:58:40Z")

</div>

Use `["JuMP", "GLPK", "Distributed"]` for the package list. I am not sure if this makes a difference. If not, maybe it is because `Distributed` is not added a dependency (even though it is in the standard library), so try `] add Distributed`, otherwise, I am not sure why it isn’t working.

---

<div class="post-metadata">

### Author: ![shce](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@shce](https://discourse.julialang.org/u/shce)
#### Post date: [October 20, 2022, 6:54am UTC](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917/27 "2022-10-20T06:54:02Z")

</div>

I cannot use an array of strings, there is no method matching. I guess it is because in version 1.4.1 of PackageCompiler only an array of symbols could be provided.

It is a pity we could not find the issue…

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [October 20, 2022, 7:56am UTC](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917/28 "2022-10-20T07:56:47Z")

</div>

> [@shce](#):
>
> `[:JuMP, :GLPK, :Distributed]`

```julia
using JuMP, GLPK, Distributed
...

create_sysimage([JuMP, GLPK, Distributed]...)

```

---

<div class="post-metadata">

### Author: ![shce](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@shce](https://discourse.julialang.org/u/shce)
#### Post date: [October 20, 2022, 8:11am UTC](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917/29 "2022-10-20T08:11:55Z")

</div>

```julia
julia> using JuMP

julia> using GLPK

julia> using Distributed

julia> create_sysimage(["JuMP", "GLPK", "Distributed"], sysimage_path="JuMPGLPKDistributedSysimage.so")
ERROR: MethodError: no method matching create_sysimage(::Array{String,1}; sysimage_path="JuMPGLPKDistributedSysimage.so")
Closest candidates are:
  create_sysimage() at /Users/shce/.julia/packages/PackageCompiler/2yhCw/src/PackageCompiler.jl:462 got unsupported keyword argument "sysimage_path"
  create_sysimage(::Union{Array{Symbol,1}, Symbol}; sysimage_path, project, precompile_execution_file, precompile_statements_file, incremental, filter_stdlibs, replace_default, base_sysimage, isapp, julia_init_c_file, version, compat_level, soname, cpu_target, script) at /Users/shce/.julia/packages/PackageCompiler/2yhCw/src/PackageCompiler.jl:462
Stacktrace:
 [1] top-level scope at REPL[29]:1

julia> create_sysimage([JuMP, GLPK, Distributed], sysimage_path="JuMPGLPKDistributedSysimage.so")
ERROR: MethodError: no method matching create_sysimage(::Array{Module,1}; sysimage_path="JuMPGLPKDistributedSysimage.so")
Closest candidates are:
  create_sysimage() at /Users/shce/.julia/packages/PackageCompiler/2yhCw/src/PackageCompiler.jl:462 got unsupported keyword argument "sysimage_path"
  create_sysimage(::Union{Array{Symbol,1}, Symbol}; sysimage_path, project, precompile_execution_file, precompile_statements_file, incremental, filter_stdlibs, replace_default, base_sysimage, isapp, julia_init_c_file, version, compat_level, soname, cpu_target, script) at /Users/shce/.julia/packages/PackageCompiler/2yhCw/src/PackageCompiler.jl:462
Stacktrace:
 [1] top-level scope at REPL[30]:1

```

I guess it should be an array of symbol for version 1.4.1 of PackageCompiler, see [here](https://github.com/JuliaLang/PackageCompiler.jl/blob/99cba4580b8ee243bb2fad81bd59e71af7b22324/src/PackageCompiler.jl#L462).

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [October 20, 2022, 8:24am UTC](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917/30 "2022-10-20T08:24:58Z")

</div>

you’re right,

but also, this is quite old

> [@shce](#):
>
> 1.4.1 of PackageCompiler

---

<div class="post-metadata">

### Author: ![shce](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@shce](https://discourse.julialang.org/u/shce)
#### Post date: [October 20, 2022, 8:28am UTC](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917/31 "2022-10-20T08:28:22Z")

</div>

I cannot update it:

```julia
(@v1.5) pkg> status PackageCompiler
Status `~/.julia/environments/v1.5/Project.toml`
  [9b87118b] PackageCompiler v1.4.1

(@v1.5) pkg> update PackageCompiler
   Updating registry at `~/.julia/registries/General`
######################################################################## 100.0%
No Changes to `~/.julia/environments/v1.5/Project.toml`
No Changes to `~/.julia/environments/v1.5/Manifest.toml`

(@v1.5) pkg> status PackageCompiler
Status `~/.julia/environments/v1.5/Project.toml`
  [9b87118b] PackageCompiler v1.4.1

(@v1.5) pkg> 

```

Perhaps it is due to the julia version.

---

<div class="post-metadata">

### Author: ![jmair](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmair/32/35117_2.png) [@jmair](https://discourse.julialang.org/u/jmair)
#### Post date: [October 20, 2022, 8:36am UTC](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917/32 "2022-10-20T08:36:46Z")

</div>

Is [First call latency in distributed code - #19 by jmair](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917/19) not an option for updating the Julia version? If you want to still use the “module load” syntax for the cluster then I have a modulefile you can use (you don’t need any admin rights, and should work the same as if the admins installed it themselves). On your own local machine, you can use `juliaup`, and switch back to your old version if things don’t work out.

---

<div class="post-metadata">

### Author: ![shce](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@shce](https://discourse.julialang.org/u/shce)
#### Post date: [October 20, 2022, 8:51am UTC](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917/33 "2022-10-20T08:51:36Z")

</div>

Yes, it is but I’m afraid that updating julia will break my code. I prefer not to update any software in the middle of a project. Nonetheless, based on your recommendations, I think it is worth installing the newest version of julia in my laptop and the cluster and see if problems are resolved…

---

<div class="post-metadata">

### Author: ![jmair](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmair/32/35117_2.png) [@jmair](https://discourse.julialang.org/u/jmair)
#### Post date: [October 20, 2022, 8:57am UTC](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917/34 "2022-10-20T08:57:16Z")

</div>

I agree with you on not updating during a project, and I usually feel the same, but when I did update, the code changes were extremely small, the main time was spent just updating the packages and precompiling.

Fortunately, each point release in Julia is non-breaking, but it’s the packages you have to be careful of. Keep a note of your current versions and if a specific package runs into trouble, you can always pin it at an earlier version using a `[compat]` header.

---

<div class="post-metadata">

### Author: ![shce](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@shce](https://discourse.julialang.org/u/shce)
#### Post date: [October 20, 2022, 9:07am UTC](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917/35 "2022-10-20T09:07:48Z")

</div>

Alternatively, what about [flag -L](https://docs.julialang.org/en/v1/manual/command-line-options/#Command-line-switches-for-Julia) when starting julia? Does it make sense?

---

<div class="post-metadata">

### Author: ![jmair](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmair/32/35117_2.png) [@jmair](https://discourse.julialang.org/u/jmair)
#### Post date: [October 20, 2022, 9:20am UTC](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917/36 "2022-10-20T09:20:48Z")

</div>

That’s good option I didn’t know about, but it won’t precompile your code in the way you want.

---

<div class="post-metadata">

### Author: ![shce](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@shce](https://discourse.julialang.org/u/shce)
#### Post date: [October 20, 2022, 9:25am UTC](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917/37 "2022-10-20T09:25:12Z")

</div>

Argh… Thank you. I will report back as soon as I manage to update julia.

---

<div class="post-metadata">

### Author: ![shce](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@shce](https://discourse.julialang.org/u/shce)
#### Post date: [October 20, 2022, 2:49pm UTC](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917/38 "2022-10-20T14:49:21Z")

</div>

It seems that the same behavior is observed for v1.6.

Interestingly, I tried my code for medium-complicated functions and it scales reasonably. Currently, I am investigating the issue for the most complicated function (it is with such function when I encounter the problem discussed herein). If it turns out it is something related to my specific function, it is a problem I have to solve myself. Otherwise, I will reopen the discussion.

Apologies and thank you very much.

shce

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [October 20, 2022, 3:04pm UTC](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917/39 "2022-10-20T15:04:18Z")

</div>

> [@shce](#):
>
> `@v1.5`

use 1.8 if possible?

---

<div class="post-metadata">

### Author: ![shce](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@shce](https://discourse.julialang.org/u/shce)
#### Post date: [October 20, 2022, 4:08pm UTC](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917/40 "2022-10-20T16:08:51Z")

</div>

> [@shce](#):
>
> It seems that the same behavior is observed for v1.6.

@jling , I tried with v1.6 since it is the LTS currently.

[Previous page](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917.md?page=1)

[Next page](https://discourse.julialang.org/t/first-call-latency-in-distributed-code/88917.md?page=3)
