# Thread overhead variability across machines

**URL:** https://discourse.julialang.org/t/thread-overhead-variability-across-machines/7320
**Category:** Performance
**Created:** [November 26, 2017, 10:06am UTC](https://discourse.julialang.org/t/thread-overhead-variability-across-machines/7320 "2017-11-26T10:06:07Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![alee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alee/32/2954_2.png) [@alee](https://discourse.julialang.org/u/alee)
#### Post date: [November 27, 2017, 9:40pm UTC](https://discourse.julialang.org/t/thread-overhead-variability-across-machines/7320/8 "2017-11-27T21:40:33Z")

</div>

Yes, certainly the performance difference can be huge when TSC is not being used. I am very unclear on how often TSC is turned off on multi-processor, multi-core systems, but it doesn’t not seem to be that rare.

I don’t know much about the intended use, but I wonder if the code that is executed when `PROFILE_JL_THREADING=1` could instead be run only when profiling is requested, similar to other profiling calls in julia. I see very few calls to `jl_threading_profile` across GitHub so it may not be commonly used.

[GitHub search for jl\_threading\_profile](https://github.com/search?q=jl_threading_profile&type=Code&utf8=%E2%9C%93)

The `JULIA_THREAD_SLEEP_THRESHOLD` variable is also a bit interesting in that although there is a benefit in sleeping spinning threads, the code that is executed has a performance impact even when the threads are working. This seems also to be true for systems with TSC. On the OSX machine:

Standard Julia

```julia
nthreads = 1 : 258.688 ns (1 allocation: 32 bytes)
nthreads = 2 : 443.434 ns (1 allocation: 32 bytes)
nthreads = 4 : 751.000 ns (1 allocation: 32 bytes)

```

Setting `PROFILE_JL_THREADING=0`

```julia
nthreads = 1 : 97.810 ns (1 allocation: 32 bytes)
nthreads = 2 : 236.790 ns (1 allocation: 32 bytes)
nthreads = 4 : 437.035 ns (1 allocation: 32 bytes)

```

`JULIA_THREAD_SLEEP_THRESHOLD=0` and `PROFILE_JL_THREADING=0`

```julia
nthreads = 1 : 52.644 ns (1 allocation: 32 bytes)
nthreads = 2 : 169.125 ns (1 allocation: 32 bytes)
nthreads = 4 : 408.315 ns (1 allocation: 32 bytes)

```

Not nearly as striking as for the E5 with TSC off, but could still make a difference.

---

_[View the full topic](https://discourse.julialang.org/t/thread-overhead-variability-across-machines/7320)._
