Performance issue with fiber

Ali Çehreli acehreli at yahoo.com
Wed Jul 28 16:31:49 UTC 2021


On 7/28/21 1:15 AM, hanabi1224 wrote:

 > On Wednesday, 28 July 2021 at 01:12:16 UTC, Denis Feklushkin wrote:
 >> Spawning fiber is expensive
 >
 > Sorry but I cannot agree with the logic behind this statement, the whole
 > point of using fiber is that, spwaning system thread is expensive, thus
 > ppl create lightweight thread 'fiber'

I assume the opposite because normally, the number of times a thread or 
fiber is spawned is nothing compared to the number of times they are 
context-switched. So, spawning can be expensive and nobody would realize 
as long as switching is cheap.

There are other reasons why fibers are faster than threads all related 
to context switching:

- CPU cache efficiency

- Translation lookaside buffer (TLB) efficiency

- Holding on to the entirety of the time slice given by the OS

Ali

P.S. The little I know on these topics is included in this presentation:

   https://dconf.org/2016/talks/cehreli.html



More information about the Digitalmars-d-learn mailing list