Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #17272

Re: Why is java consumer/producer so much faster than C++

From Luca Risolia <luca.risolia@studio.unibo.it>
Newsgroups comp.lang.c++
Subject Re: Why is java consumer/producer so much faster than C++
Date 2012-07-26 23:12 +0200
Organization Aioe.org NNTP Server
Message-ID <jusbsi$2e5$3@speranza.aioe.org> (permalink)
References (6 earlier) <jumu0i$luo$1@news.albasani.net> <jus57m$2e5$1@speranza.aioe.org> <jus7di$hkm$7@news.albasani.net> <jus8h1$2e5$2@speranza.aioe.org> <jusb87$hkm$10@news.albasani.net>

Show all headers | View raw


On 26/07/2012 23:01, Melzzzzz wrote:
> On Thu, 26 Jul 2012 22:15:33 +0200
> Luca Risolia <luca.risolia@studio.unibo.it> wrote:
>
>> On 26/07/2012 21:56, Melzzzzz wrote:
>>>>            f = ++f % cap_;
>>>
>>> compiler warns about undefined behavior here.
>>
>> Ouch..split that:
>>
>> ++f;
>> f %= cap_;
>
> I corrected that already ;)
>
> I have installed gcc-snapshot compiler
> gcc version 4.8.0 20120314 (experimental) [trunk revision 185382]
> (Ubuntu/Linaro 20120314-0ubuntu2)
>
> Your timings with array assignment and rand included, are much worse
> than gcc 4.6.3. Definitely something is wrong if
> other thread does something else besides waiting on
> spin lock.

Yes, it's worth to strace std::rand() to see what it does exactly.
Out of my curiosity, try to yield() after releasing the lock in both 
put() and take():

             m_.unlock();
             boost::this_thread::yield(); // add this line

do you see any improvements?

Back to comp.lang.c++ | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Why is java consumer/producer so much faster than C++ Melzzzzz <mel@zzzzz.com> - 2012-07-22 23:59 +0200
  Re: Why is java consumer/producer so much faster than C++ Joshua Maurice <joshuamaurice@gmail.com> - 2012-07-22 15:42 -0700
    Re: Why is java consumer/producer so much faster than C++ Melzzzzz <mel@zzzzz.com> - 2012-07-23 01:28 +0200
      Re: Why is java consumer/producer so much faster than C++ Luca Risolia <luca.risolia@studio.unibo.it> - 2012-07-23 02:03 +0200
        Re: Why is java consumer/producer so much faster than C++ Melzzzzz <mel@zzzzz.com> - 2012-07-23 12:17 +0200
          Re: Why is java consumer/producer so much faster than C++ Luca Risolia <luca.risolia@studio.unibo.it> - 2012-07-24 00:33 +0200
            Re: Why is java consumer/producer so much faster than C++ Bo Persson <bop@gmb.dk> - 2012-07-24 19:50 +0200
  Re: Why is java consumer/producer so much faster than C++ Juha Nieminen <nospam@thanks.invalid> - 2012-07-23 06:37 +0000
    Re: Why is java consumer/producer so much faster than C++ Melzzzzz <mel@zzzzz.com> - 2012-07-23 12:33 +0200
      Re: Why is java consumer/producer so much faster than C++ Juha Nieminen <nospam@thanks.invalid> - 2012-07-23 11:46 +0000
        Re: Why is java consumer/producer so much faster than C++ Melzzzzz <mel@zzzzz.com> - 2012-07-23 15:33 +0200
  Re: Why is java consumer/producer so much faster than C++ Zoltan Juhasz <zoltan.juhasz@gmail.com> - 2012-07-23 06:57 -0700
    Re: Why is java consumer/producer so much faster than C++ Melzzzzz <mel@zzzzz.com> - 2012-07-23 18:42 +0200
      Re: Why is java consumer/producer so much faster than C++ Howard Hinnant <howard.hinnant@gmail.com> - 2012-07-23 13:23 -0700
        Re: Why is java consumer/producer so much faster than C++ Melzzzzz <mel@zzzzz.com> - 2012-07-24 00:32 +0200
          Re: Why is java consumer/producer so much faster than C++ Howard Hinnant <howard.hinnant@gmail.com> - 2012-07-23 18:11 -0700
            Re: Why is java consumer/producer so much faster than C++ Melzzzzz <mel@zzzzz.com> - 2012-07-24 11:21 +0200
            Re: Why is java consumer/producer so much faster than C++ Melzzzzz <mel@zzzzz.com> - 2012-07-24 21:45 +0200
              Re: Why is java consumer/producer so much faster than C++ Luca Risolia <luca.risolia@studio.unibo.it> - 2012-07-24 23:24 +0200
                Re: Why is java consumer/producer so much faster than C++ Melzzzzz <mel@zzzzz.com> - 2012-07-25 00:48 +0200
                Re: Why is java consumer/producer so much faster than C++ Luca Risolia <luca.risolia@studio.unibo.it> - 2012-07-25 01:21 +0200
              Re: Why is java consumer/producer so much faster than C++ Howard Hinnant <howard.hinnant@gmail.com> - 2012-07-24 17:35 -0700
              Re: Why is java consumer/producer so much faster than C++ Luca Risolia <luca.risolia@studio.unibo.it> - 2012-07-26 21:19 +0200
                Re: Why is java consumer/producer so much faster than C++ Melzzzzz <mel@zzzzz.com> - 2012-07-26 21:56 +0200
                Re: Why is java consumer/producer so much faster than C++ Luca Risolia <luca.risolia@studio.unibo.it> - 2012-07-26 22:15 +0200
                Re: Why is java consumer/producer so much faster than C++ Melzzzzz <mel@zzzzz.com> - 2012-07-26 23:01 +0200
                Re: Why is java consumer/producer so much faster than C++ Luca Risolia <luca.risolia@studio.unibo.it> - 2012-07-26 23:12 +0200
                Re: Why is java consumer/producer so much faster than C++ Melzzzzz <mel@zzzzz.com> - 2012-07-27 00:24 +0200
                Re: Why is java consumer/producer so much faster than C++ Melzzzzz <mel@zzzzz.com> - 2012-07-27 00:48 +0200
                Re: Why is java consumer/producer so much faster than C++ Melzzzzz <mel@zzzzz.com> - 2012-07-27 05:43 +0200
                Re: Why is java consumer/producer so much faster than C++ Melzzzzz <mel@zzzzz.com> - 2012-07-27 07:43 +0200
                Re: Why is java consumer/producer so much faster than C++ Marc <marc.glisse@gmail.com> - 2012-07-26 21:10 +0000
                Re: Why is java consumer/producer so much faster than C++ Donkey Hottie <donkey@fredriksson.dy.fi> - 2012-07-27 01:05 +0300
                Re: Why is java consumer/producer so much faster than C++ Paavo Helde <myfirstname@osa.pri.ee> - 2012-07-26 17:12 -0500
        Re: Why is java consumer/producer so much faster than C++ yatremblay@bel1lin202.(none) (Yannick Tremblay) - 2012-07-24 12:51 +0000
          Re: Why is java consumer/producer so much faster than C++ Melzzzzz <mel@zzzzz.com> - 2012-07-24 17:47 +0200
            Re: Why is java consumer/producer so much faster than C++ yatremblay@bel1lin202.(none) (Yannick Tremblay) - 2012-07-25 08:09 +0000
              Re: Why is java consumer/producer so much faster than C++ Howard Hinnant <howard.hinnant@gmail.com> - 2012-07-25 08:46 -0700
  Re: Why is java consumer/producer so much faster than C++ Dombo <dombo@disposable.invalid> - 2012-07-23 22:57 +0200
    Re: Why is java consumer/producer so much faster than C++ Joshua Maurice <joshuamaurice@gmail.com> - 2012-07-23 21:54 -0700
      Re: Why is java consumer/producer so much faster than C++ Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-07-24 12:50 +0000
  Re: Why is java consumer/producer so much faster than C++ James Kanze <james.kanze@gmail.com> - 2012-07-29 03:27 -0700
    Re: Why is java consumer/producer so much faster than C++ Melzzzzz <mel@zzzzz.com> - 2012-07-29 14:40 +0200
  Re: Why is java consumer/producer so much faster than C++ Ricardo Nabinger Sanchez <rnsanchez@wait4.org> - 2012-08-14 22:48 +0000

csiph-web