Function runs much slower from the Julia command prompt

Ok, so I am a relatively new Julia user. I have a program which uses parallelism. When i run a test script to execute the function from the Juno editor, the function execution speed is good.
However, when i run the same test script from the Julia prompt from Windows, the execution speed is orders of magnitude slower.
This is my simple test code:

wIntercept = true
wInteract   = true
crossValid = true
commonRun  = true

Pl = 2
Pu = 1
Nparam=500

include("main.jl")
function main_variable(wIntercept, Interact, crossValid, CommonRan, Pl, Pu, Nparam)
    return main(wIntercept, Interact, crossValid, CommonRan, Pl, Pu, Nparam)
end

For reference, the function execution is completed in ~200 seconds from Juno. However, it takes around 7000 seconds from the prompt to finish.

Without a self-contained minimum working example, it is very difficult to say what is going on.

Juno runs your code with -O3 and multithreaded by default, so maybe try that when running from the REPL.

What do you mean by multithreaded by default? Your code must use @threads for this to work, can you clarify on this, please?

1 Like

What I meant is that Juno sets ENV["JULIA_NUM_THREADS"] to something sensible (number of cores, which isn’t necessarily the best heuristic but imho better than only ever using one thread) before starting Julia, which means that if you can actually get a performance improvement from code using Threads.@threads internally.
I have no idea if OP’s code is using threads, but it would explain the rather large performance difference.

1 Like

Found the reason. I had turned off depreciation warnings in Juno sometime ago. I wasn’t running Julia repl with the depwarn no flag.