Polyester seems to be one of the bigger sources of TTFX in some of my libraries. It is similarly the main source of warnings when using JET. Below is a very simple multi-threaded loop that causes a large number of JET warnings (both in 1.7.0 and in nightly). I do not have much understanding of ThreadingUtilities and of StaticArrays, where the warnings originate. Would someone be able to guide me where to look for improvements or how I can change my function, in order to silence the JET warnings and make sure there is no risk of runtime dispatch?
julia> using JET, Polyester
julia> function a(m::Matrix, i::Int)
@batch for r in axes(m,1)
m[r,:] .+= i
end
end
a (generic function with 1 method)
julia> m = rand(Int,5,5)
julia> @report_opt a(m,1)
āāāāā 92 possible errors found āāāāā
...
It is indeed Static v0.7, but I used the wrong MWE, so that might have been a bit mislead. Please excuse the confusion. The warnings are from StaticArrays (and ThreadingUtilities), not from Static. All versions are added to the original post.
These are basically all for printing.
Iām apparently on different versions (as I get 60, not 72, possible errors found).
But everything I see comes from these two lines:
This code is for diagnostics, that is, it displays and dumps a failed task so you can see the stacktrace when your threaded code runs an error.
If your programās performance is bottlenecked by how quickly it can print error messages, Iād suggest trying to stop it from throwing so many errors. Maybe fix the bugs that keep showing up in all those stacktraces?
Or PR base Julia to speed up display(::Task) and dump(::Task), I guess.
Of course, you probably didnāt hit these lines in your code.
You just got a report from JET.
Is there some way I can hide this code from JET, so we donāt have so many false positives/its output is more useful?
I donāt think dump(::Task) is all that useful, so I can probably remove that line.
Indeed, I am not hitting these lines, they are just showing up in JETās abstract interpretation. To great extent, I am just cargo-culting my approach to lowering TTFX: I have noticed that the fewer Aqua and JET warnings I have, the faster the package imports (while I did not have as much luck with SnoopCompile), so I am spending some time trying to figure out the source of every JET warning. Admittedly, this is not the best āfirst principlesā approach, but it is educational enough, and I needed to start somewhere.
Thanks for your explanation! It does not seem there is anything more to see here. If I figure out how to tell the compiler and/or JET to not worry about these lines, I will send you a pull request.