# Bad performances when using Multithreading and Distributed with heavy LinearAlgebra calculations

**URL:** https://discourse.julialang.org/t/bad-performances-when-using-multithreading-and-distributed-with-heavy-linearalgebra-calculations/117258
**Category:** Performance
**Tags:** performance, multithreading, distributed
**Created:** [July 19, 2024, 11:47pm UTC](https://discourse.julialang.org/t/bad-performances-when-using-multithreading-and-distributed-with-heavy-linearalgebra-calculations/117258 "2024-07-19T23:47:29Z")
**Posts on this page:** 7
**Page:** 2

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [July 24, 2024, 11:42am UTC](https://discourse.julialang.org/t/bad-performances-when-using-multithreading-and-distributed-with-heavy-linearalgebra-calculations/117258/21 "2024-07-24T11:42:50Z")

</div>

Memory bound means that the performance is limited by the memory bandwidth, compute bound means the performance is limited by the speed (and number) of the CPU cores.

---

<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: [July 24, 2024, 11:56am UTC](https://discourse.julialang.org/t/bad-performances-when-using-multithreading-and-distributed-with-heavy-linearalgebra-calculations/117258/22 "2024-07-24T11:56:32Z")

</div>

> [@albertomercurio](#):
>
> Could you explain better this? What do you mean by “memory bound” and “compute bounds?

The picture to have in mind here is called [Roofline Model](https://en.wikipedia.org/wiki/Roofline_model).

In this simplified model there are essentially 2 resources: memory throughput and compute throughput. Loading and storing of values to RAM takes memory throughput and essentially everything else takes compute time. Parallelization essentially increases the available computing power but does not increase memory throughput. So using more threads only helps if you don’t saturate the memory bandwidth.

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [July 24, 2024, 12:45pm UTC](https://discourse.julialang.org/t/bad-performances-when-using-multithreading-and-distributed-with-heavy-linearalgebra-calculations/117258/23 "2024-07-24T12:45:43Z")

</div>

Well, we also have cache memory that has a much higher memory bandwidth, but only a limited size.

---

<div class="post-metadata">

### Author: ![albertomercurio](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albertomercurio/32/27051_2.png) [@albertomercurio](https://discourse.julialang.org/u/albertomercurio)
#### Post date: [July 25, 2024, 12:49pm UTC](https://discourse.julialang.org/t/bad-performances-when-using-multithreading-and-distributed-with-heavy-linearalgebra-calculations/117258/24 "2024-07-25T12:49:47Z")

</div>

Is the cache automatically used in Julia, when the array size fits the cache size?

---

<div class="post-metadata">

### Author: ![albertomercurio](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albertomercurio/32/27051_2.png) [@albertomercurio](https://discourse.julialang.org/u/albertomercurio)
#### Post date: [July 25, 2024, 12:53pm UTC](https://discourse.julialang.org/t/bad-performances-when-using-multithreading-and-distributed-with-heavy-linearalgebra-calculations/117258/25 "2024-07-25T12:53:26Z")

</div>

By the way, thanks to everyone who made it much more clear the situation.

---

<div class="post-metadata">

### Author: ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)
#### Post date: [July 25, 2024, 1:04pm UTC](https://discourse.julialang.org/t/bad-performances-when-using-multithreading-and-distributed-with-heavy-linearalgebra-calculations/117258/26 "2024-07-25T13:04:53Z")

</div>

This isn’t a Julia thing but a chip thing. CPUs don’t expose the ability to manage cached memory. The most recently used memory just always gets put in cache.

---

<div class="post-metadata">

### Author: ![albertomercurio](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albertomercurio/32/27051_2.png) [@albertomercurio](https://discourse.julialang.org/u/albertomercurio)
#### Post date: [July 25, 2024, 10:59pm UTC](https://discourse.julialang.org/t/bad-performances-when-using-multithreading-and-distributed-with-heavy-linearalgebra-calculations/117258/27 "2024-07-25T22:59:58Z")

</div>

Ok, thanks a lot.

[Previous page](https://discourse.julialang.org/t/bad-performances-when-using-multithreading-and-distributed-with-heavy-linearalgebra-calculations/117258.md?page=1)
