Looks like the multithreading is causing a type instability since order isn’t being constant-propagated across the task boundary. I’d rewrite it like this:
function run_v2_static_view(::Val{order}) where {order}
A = LinRange(0,1,1_000_000)
F = A.^4
t = 0.3
Threads.@threads for i ∈ 1:10000
xnodes = SVector{order}(@view(A[i:i+order-1]))
fvals = SVector{order}(@view(F[i:i+order-1]))
u = v2(xnodes,fvals, t)
end
end
julia> @btime run_v2_static_view(Val(6))
3.371 ms (39 allocations: 7.63 MiB)