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

**URL:** <https://discourse.julialang.org/t/julia-multithreading-is-running-slower-than-serial-can-someone-please-explain-why-general-usage-performance-multithreading-floops/96657>\
**Category:** Performance\
**Tags:** multithreading, floops\
**Created:** [March 27, 2023, 12:25pm UTC](https://discourse.julialang.org/t/julia-multithreading-is-running-slower-than-serial-can-someone-please-explain-why-general-usage-performance-multithreading-floops/96657 "2023-03-27T12:25:57Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/224680_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [March 27, 2023, 7:38pm UTC](https://discourse.julialang.org/t/julia-multithreading-is-running-slower-than-serial-can-someone-please-explain-why-general-usage-performance-multithreading-floops/96657/4 "2023-03-27T19:38:06Z")

</div>

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](https://discourse.julialang.org/t/type-instability-because-of-threads-boxing-variables/78395/11)

---

_[View the full topic](https://discourse.julialang.org/t/julia-multithreading-is-running-slower-than-serial-can-someone-please-explain-why-general-usage-performance-multithreading-floops/96657)._
