Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
June 14, 2015 CPU cores & threads & fibers | ||||
---|---|---|---|---|
| ||||
Hi, just to x-check if I have the correct understanding:
fibers = look parallel, are sequential => use 1 CPU core
threads = look parallel, are parallel => use several CPU cores
Is that right?
--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster
|
June 14, 2015 Re: CPU cores & threads & fibers | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert M. Münch | On Sunday, 14 June 2015 at 12:35:44 UTC, Robert M. Münch wrote:
> Hi, just to x-check if I have the correct understanding:
>
> fibers = look parallel, are sequential => use 1 CPU core
> threads = look parallel, are parallel => use several CPU cores
>
> Is that right?
Pretty much.
|
June 14, 2015 Re: CPU cores & threads & fibers | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert M. Münch | On 2015-06-14 08:35, Robert M. Münch wrote: > Hi, just to x-check if I have the correct understanding: > > fibers = look parallel, are sequential => use 1 CPU core > threads = look parallel, are parallel => use several CPU cores > > Is that right? > Yes, however nothing really guarantees multi-threading = multi-core. The kernel reserves the right and will most likely do everything possible to keep your process core-local to use caching efficiently. There's a few ways around that though https://msdn.microsoft.com/en-us/library/windows/desktop/ms686247%28v=vs.85%29.aspx http://man7.org/linux/man-pages/man2/sched_setaffinity.2.html |
June 14, 2015 Re: CPU cores & threads & fibers | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert M. Münch | On Sunday, 14 June 2015 at 12:35:44 UTC, Robert M. Münch wrote:
> Hi, just to x-check if I have the correct understanding:
>
> fibers = look parallel, are sequential => use 1 CPU core
> threads = look parallel, are parallel => use several CPU cores
>
> Is that right?
Fibers/co-routines run on a thread and is conceptually the same as a functor/object-with-method that can suspend itself and hold onto the state until it is restarted. Like yield in Python generators.
Fibers have their own stack, but that is an implementation detail. It is possible to do the same thing with object-method-calls if you have stackless code-generation (D does not support stackless runtimes, but you'll find this in other languages).
|
June 15, 2015 Re: CPU cores & threads & fibers | ||||
---|---|---|---|---|
| ||||
Posted in reply to Etienne Cimon | On 2015-06-14 15:54:30 +0000, Etienne Cimon said: > Yes, however nothing really guarantees multi-threading = multi-core. The kernel reserves the right and will most likely do everything possible to keep your process core-local to use caching efficiently. Hi, sure. It's more about raising the chance to use the cores ;-) -- Robert M. Münch http://www.saphirion.com smarter | better | faster |
June 16, 2015 Re: CPU cores & threads & fibers | ||||
---|---|---|---|---|
| ||||
Posted in reply to Etienne Cimon | On Sunday, 14 June 2015 at 15:54:30 UTC, Etienne Cimon wrote: > On 2015-06-14 08:35, Robert M. Münch wrote: >> Hi, just to x-check if I have the correct understanding: >> >> fibers = look parallel, are sequential => use 1 CPU core >> threads = look parallel, are parallel => use several CPU cores >> >> Is that right? >> > > Yes, however nothing really guarantees multi-threading = multi-core. The kernel reserves the right and will most likely do everything possible to keep your process core-local to use caching efficiently. > > There's a few ways around that though > > https://msdn.microsoft.com/en-us/library/windows/desktop/ms686247%28v=vs.85%29.aspx > http://man7.org/linux/man-pages/man2/sched_setaffinity.2.html FYI: https://issues.dlang.org/show_bug.cgi?id=11686 https://issues.dlang.org/show_bug.cgi?id=11687 |
June 18, 2015 Re: CPU cores & threads & fibers | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rob T | On 2015-06-16 18:36:09 +0000, Rob T said: > FYI: > > https://issues.dlang.org/show_bug.cgi?id=11686 > https://issues.dlang.org/show_bug.cgi?id=11687 Thanks. We are currently experimenting to see how want to use the threads and what code to refactor. If we are going to bite the bullet I keep this in mind, maybe we can contribute something along. -- Robert M. Münch http://www.saphirion.com smarter | better | faster |
Copyright © 1999-2021 by the D Language Foundation