Profiler doesn't show Threads

I want to use multithreading in a project. I use Julia in VS Code and use the build-in profiler of the VSCode extension. The 8 threads appear in the profiler dropdown menu, but all threads except the first only have one horizontal block that says “root” and it seems as if they are not used at all.

I’m using windows. I start julia with 8 threads and Threads.nthreads() returns 8. I used the example from Polyester.jl and increased the size of x and y to 10 000 000, because I want to benchmark it and use the Profiler and I got the “There were no samples collected.” warning with smaller arrays.

I think that multiple threads are used since the benchmark times vary between the functions and I can see in the windows task manager, that multiple cores work when executing the multithreaded functions.
As described above, the profiler doesn’t indicate that any work is done in the 7 other threads. I tried to use ProfileView instead of the VSCode profiler and it doesn’t even display any indication that there is more than one thread.

  1. Has someone ideas why this is happening?
  2. In case the Polyester code is a bad example, could someone suggest a better one?
1 Like

I’m speculating but I believe that by using Polyester that you bypassed Julia’s traditional threading mechanisms.

Have you tried just using Threads.@threads?

https://docs.julialang.org/en/v1/manual/multi-threading/#The-@threads-Macro

Otherwise you may want to use Intel’s Vtune oe a similar profiler instead.

1 Like

As Windows developers seem to be a rare commodity, the code for multithreaded sampling has not yet been written for Windows. There is all the data needed and structures present, but nobody has yet bothered to submit a PR to add the requisite for-loop over all of the threads. That could be you?

The docs missed a note on this. Profile: add notes to `print()` docs by IanButterworth · Pull Request #53205 · JuliaLang/julia · GitHub
However if you tried to use Profile.print(groupby = :threads) on Windows there is a warning.

True. Note that the missing amount of code is fairly silly, as it already has the code to sample all threads here, but then hard-codes thread 0 instead of using a for-loop julia/src/signals-win.c at 94fd312df03d5075796fbd2e8b47288a84a1c6de · JuliaLang/julia · GitHub

Thank you for asking! I’ve wondered about tis always too, but never thought too ask :slight_smile:

I am on Windows and have the same issue.

Kind regards

Thank you, that was the issue, I tried it in WSL and all the threads are visible!