Session Info
```r
─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
setting value
version R version 4.0.4 (2021-02-15)
os openSUSE Leap 15.3
system x86_64, linux-gnu
ui RStudio
language (EN)
collate en_GB.UTF-8
ctype en_GB.UTF-8
tz Europe/London
date 2021-08-17
```
We have a relatively complex piece of code that we wrote in Julia but want to be able to access and run from R, and we have successfully used JuliaCall to do this.
However, we have noticed that our code is around 40% slower when we run it from RStudio via JuliaCall as compared to running it in the REPL (based on btime).
We have observed similar, but less extreme behaviour (only around 10% slower), from the following
using BenchmarkTools
function f()
a = [1:100; ]
@btime f = ($a .< 70)
return nothing
end
f()
library(JuliaCall)
julia_command("using BenchmarkTools")
julia_command("function f()
a = [1:100; ]
@btime f = ($a .< 70)
return nothing
end")
julia_command("f()")
where on my particular machine I get
288.673 ns (2 allocations: 128 bytes) via REPL
312.759 ns (2 allocations: 128 bytes) via JuliaCall in RStudio
311.442 ns (2 allocations: 128 bytes) via JuliaCall in R terminal
By email, NoContradiction noted that there should not be much performance difference between the two and indeed that was the case when they ran the above on their machine (<1 % difference). They suggested it could be something to do with the os system and configuration, in particular that the embedded Julia in R will be subject to the number of threads and memory of R and it is also theoretically possible that JuliaCall and Julia REPL could link to different C libraries with different performance.
I have tried to find such a difference but without luck (or perhaps competence).
For example, I get identical results from calling versioninfo() in the embedded Julia in R or in the REPL
JuliaCall::julia_command("versioninfo()")
Julia Version 1.5.1
Commit 697e782ab8 (2020-08-25 20:08 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Xeon(R) CPU E5-2687W v3 @ 3.10GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-9.0.1 (ORCJIT, haswell)
and I can't see any obvious differences when comparing any of the "Sys" module calls (in particular relating to total and free memory), and both instances claim there are 40 CPUs available.
Does anyone have any further suggestions or advice as to what could be going on here?
Session Info
```r ─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── setting value version R version 4.0.4 (2021-02-15) os openSUSE Leap 15.3 system x86_64, linux-gnu ui RStudio language (EN) collate en_GB.UTF-8 ctype en_GB.UTF-8 tz Europe/London date 2021-08-17 ```We have a relatively complex piece of code that we wrote in Julia but want to be able to access and run from R, and we have successfully used JuliaCall to do this.
However, we have noticed that our code is around 40% slower when we run it from RStudio via JuliaCall as compared to running it in the REPL (based on btime).
We have observed similar, but less extreme behaviour (only around 10% slower), from the following
where on my particular machine I get
288.673 ns (2 allocations: 128 bytes)
via REPL312.759 ns (2 allocations: 128 bytes)
via JuliaCall in RStudio311.442 ns (2 allocations: 128 bytes)
via JuliaCall in R terminalBy email, NoContradiction noted that there should not be much performance difference between the two and indeed that was the case when they ran the above on their machine (<1 % difference). They suggested it could be something to do with the os system and configuration, in particular that the embedded Julia in R will be subject to the number of threads and memory of R and it is also theoretically possible that JuliaCall and Julia REPL could link to different C libraries with different performance.
I have tried to find such a difference but without luck (or perhaps competence).
For example, I get identical results from calling
versioninfo()
in the embedded Julia in R or in the REPLand I can't see any obvious differences when comparing any of the "Sys" module calls (in particular relating to total and free memory), and both instances claim there are 40 CPUs available.
Does anyone have any further suggestions or advice as to what could be going on here?