I have a a hot loop function which merges 2 SparseVector of 1k items each.
With @benchmark I can see that adding conditionWhichIsFalse && @warn lazy"msg $myIntVariable"
after the loop, makes the function 3 times slower (25us instead of 8us).
Converting to conditionWhichIsFalse && @warn "msg" myIntVariable"
solves it.
Is the compiler not optimizing the function because it finds it too complex when adding the string interpolation?
Any best practice or tool to mitigate or diagnose this kind of problems?
Without having checked, I think what you’re seeing is that the string from the interpolation might be constructed regardless. Or that the effects of creating a string through interpolation disable some other optimization the compiler is ordinarily able to do.