# Struggling with creating a faster threaded version of a concurrent problem

**URL:** <https://discourse.julialang.org/t/struggling-with-creating-a-faster-threaded-version-of-a-concurrent-problem/104549>\
**Category:** Performance\
**Created:** [October 3, 2023, 7:14pm UTC](https://discourse.julialang.org/t/struggling-with-creating-a-faster-threaded-version-of-a-concurrent-problem/104549 "2023-10-03T19:14:35Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)\
**Post date:** [October 4, 2023, 7:29am UTC](https://discourse.julialang.org/t/struggling-with-creating-a-faster-threaded-version-of-a-concurrent-problem/104549/10 "2023-10-04T07:29:08Z")

</div>

So I don’t think that without something runnable, people here are able to help you (well except pointing at random things and making general statements). For starters it does not need to be MWE just easy to setup and run in some form.

Concerning multithreading: I think your workloads are quite short right now, so the overhead of threading (spawning a Task and scheduling it) might outweigh the speedup. I found [this old thread](https://discourse.julialang.org/t/overhead-of-threads-threads/53964/2) where the overhead of `Threads.@threads` is O(10µs). To get good speedups in short sections there are different libraries such as [Polyester.jl](https://github.com/JuliaSIMD/Polyester.jl). But I personally think we should try to optimize the single threaded case first to get back at the speed of your C++ implementation.

Of course finding the segfault would be very interesting! A quick and easy check would be removing all `@inbounds` from your code base. If the segfault still occurs, then it really might be a bug in Julia which will be harder to isolate.

---

_[View the full topic](https://discourse.julialang.org/t/struggling-with-creating-a-faster-threaded-version-of-a-concurrent-problem/104549)._
