Julia multithreading is running slower than serial, can someone please explain why…? General Usage Performance multithreading floops

Could you profile the code to see if the switch! function has any red descendents in the flame graph? Indeed it seems like it doesn’t allocate, so the problem must come from elsewhere. I have this vague memory that multithreading with @threads or @floops can introduce type instabilities (although IIRC @floops at least warns you about it). The thing that put me on the track is that type instability can often result in excessive allocations

See Type-instability because of @threads boxing variables - #11 by lmiq