# MCMCDistributed or MCMCThreads?

**URL:** https://discourse.julialang.org/t/mcmcdistributed-or-mcmcthreads/99756
**Category:** New to Julia
**Tags:** multithreading, distributed, turing
**Created:** [June 2, 2023, 8:47am UTC](https://discourse.julialang.org/t/mcmcdistributed-or-mcmcthreads/99756 "2023-06-02T08:47:53Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Sahil\_Khan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sahil_khan/32/47573_2.png) [@Sahil\_Khan](https://discourse.julialang.org/u/Sahil_Khan)
#### Post date: [June 2, 2023, 8:47am UTC](https://discourse.julialang.org/t/mcmcdistributed-or-mcmcthreads/99756/1 "2023-06-02T08:47:53Z")

</div>

Which one is better to make inference fast and why? Does they have any effect if you are using single chain?

---

<div class="post-metadata">

### Author: ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)
#### Post date: [June 2, 2023, 10:29am UTC](https://discourse.julialang.org/t/mcmcdistributed-or-mcmcthreads/99756/2 "2023-06-02T10:29:05Z")

</div>

In my experience, they have similar performance. You can run a benchmark to verify for your use case. Using a single distributed or threaded chain will not provide a performance advantage because sampling is performed serially within a chain.

---

<div class="post-metadata">

### Author: ![mcreel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcreel/32/30088_2.png) [@mcreel](https://discourse.julialang.org/u/mcreel)
#### Post date: [June 2, 2023, 12:08pm UTC](https://discourse.julialang.org/t/mcmcdistributed-or-mcmcthreads/99756/3 "2023-06-02T12:08:30Z")

</div>

I have used the two methods, for the same model. My casual observation makes me think that Distributed is somewhat faster. I believe that garbage collection on one thread slows all, while the same is not true for different workers. I will try to do a more careful comparison before long.

---

<div class="post-metadata">

### Author: ![Sahil\_Khan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sahil_khan/32/47573_2.png) [@Sahil\_Khan](https://discourse.julialang.org/u/Sahil_Khan)
#### Post date: [June 2, 2023, 12:10pm UTC](https://discourse.julialang.org/t/mcmcdistributed-or-mcmcthreads/99756/4 "2023-06-02T12:10:38Z")

</div>

At the moment I also see similar results as you said.
