Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming.threads > #1504
| Newsgroups | comp.programming.threads |
|---|---|
| Subject | Re: Thread scaling in Windows |
| From | Paavo Helde <myfirstname@osa.pri.ee> |
| References | <XnsA1CFD0BECDBADmyfirstnameosapriee@216.196.109.131> <51a7c499$0$6565$9b4e6d93@newsspool4.arcor-online.net> <XnsA1D1132254871myfirstnameosapriee@216.196.109.131> <51a8ab52$0$6567$9b4e6d93@newsspool4.arcor-online.net> |
| Organization | PKI |
| Message-ID | <XnsA1D1D5409B3C5myfirstnameosapriee@216.196.109.131> (permalink) |
| Date | 2013-05-31 12:57 -0500 |
Marcel Müller <news.5.maazl@spamgourmet.org> wrote in news:51a8ab52$0$6567$9b4e6d93@newsspool4.arcor-online.net: > On 31.05.13 00.52, Paavo Helde wrote: >>> Most likely you enter the mutexes very often during calculation. >>> This >> is >>> bad practice. If you want to run in parallel, then run in parallel >>> and do not talk to each other over an over. >> >> Mutexes are indeed entered quite often, but most of the cases there >> should be no contention and the mutex is locked for a very short >> time, > > This does not care. Think of that: entering a mutex requires to > synchronize all cores with memory. Even at lowest level one clock > cycle of 1GHz (very few nowadays) is only enough for synchronizing > over a distance of about 10 cm, simply because the speed of the > electric fields (about 70% of the speed of light). Enough to reach the > memory chips, but no more. Switching times of the electronics will > additionally reduce the speed. So even at assembly level, e.g. with > lock-free algorithms, synchronization (= memory barriers) are > expensive nowadays. > >> like updating a shared object reference count by a smartpointer. > > This is really expensive! Not only because of the mutex. Writing to a > shared memory location from different cores also invalidates the > related cache content of all cores except for the one currently > writing. So cache misses are very likely to occur after that. The > problem is called cache line hopping, and you simply should not do > that. Right, this is something I have vaguely suspected myself. Trying to get rid of them. But this does not explain the Linux-Windows difference, does it? > > But if so, why do you write to a shared smart pointer all the time? We have two kinds of refcounted smartpointers - for single-threaded and shared objects. Mostly the single-threaded objects are used, otherwise there would be hundreds of times more mutex locks. Shared objects are accessed only occasionally, but this still makes up a lot as it seems. In principle it should suffice to have only one shared object smartpointer in a thread and use C++ references for passing it around in the thread. Thanks for the answers! Paavo
Back to comp.programming.threads | Previous | Next — Previous in thread | Next in thread | Find similar
Thread scaling in Windows Paavo Helde <myfirstname@osa.pri.ee> - 2013-05-29 12:31 -0500
Re: Thread scaling in Windows Robert Miles <robertmilesxyz@gmail.com> - 2013-05-29 17:26 -0700
Re: Thread scaling in Windows Paavo Helde <myfirstname@osa.pri.ee> - 2013-05-30 16:11 -0500
Re: Thread scaling in Windows Gerald Breuer <Gerald.Breuer@googlemail.com> - 2013-05-31 03:44 +0200
Re: Thread scaling in Windows Paavo Helde <myfirstname@osa.pri.ee> - 2013-05-31 00:29 -0500
Re: Thread scaling in Windows Marcel Müller <news.5.maazl@spamgourmet.org> - 2013-05-30 23:28 +0200
Re: Thread scaling in Windows Paavo Helde <myfirstname@osa.pri.ee> - 2013-05-30 17:52 -0500
Re: Thread scaling in Windows Melzzzzz <mel@zzzzz.com> - 2013-05-31 04:18 +0200
Re: Thread scaling in Windows Robert Wessel <robertwessel2@yahoo.com> - 2013-05-31 01:11 -0500
Re: Thread scaling in Windows Paavo Helde <myfirstname@osa.pri.ee> - 2013-06-01 12:15 -0500
Re: Thread scaling in Windows Paavo Helde <myfirstname@osa.pri.ee> - 2013-06-01 16:52 -0500
Re: Thread scaling in Windows [SOLVED] Paavo Helde <myfirstname@osa.pri.ee> - 2013-06-03 12:00 -0500
Re: Thread scaling in Windows [SOLVED] Casper H.S. Dik <Casper.Dik@OrSPaMcle.COM> - 2013-06-04 08:16 +0000
Re: Thread scaling in Windows [SOLVED] Noob <root@127.0.0.1> - 2013-06-04 10:25 +0200
Re: Thread scaling in Windows Marcel Müller <news.5.maazl@spamgourmet.org> - 2013-05-31 15:53 +0200
Re: Thread scaling in Windows Paavo Helde <myfirstname@osa.pri.ee> - 2013-05-31 12:57 -0500
Re: Thread scaling in Windows Marcel Müller <news.5.maazl@spamgourmet.org> - 2013-05-31 22:59 +0200
Re: Thread scaling in Windows Paavo Helde <myfirstname@osa.pri.ee> - 2013-06-01 03:06 -0500
Re: Thread scaling in Windows Marcel Müller <news.5.maazl@spamgourmet.org> - 2013-06-01 15:20 +0200
Re: Thread scaling in Windows Drazen Kacar <dave@fly.srk.fer.hr> - 2013-06-02 06:35 +0000
Re: Thread scaling in Windows Casper H.S. Dik <Casper.Dik@OrSPaMcle.COM> - 2013-06-01 12:34 +0000
Re: Thread scaling in Windows Marcel Müller <news.5.maazl@spamgourmet.org> - 2013-06-01 15:09 +0200
Re: Thread scaling in Windows Casper H.S. Dik <Casper.Dik@OrSPaMcle.COM> - 2013-06-01 17:12 +0000
csiph-web