[concurrency-interest] Blocking vs. non-blocking

Dennis Sosnoski dms at sosnoski.com
Sat Jun 14 00:34:25 EDT 2014


Wow, I don't even recognized C++ code anymore. This doesn't seem to 
really address the issue of why non-blocking, though, aside from the UI 
responsiveness issue (which most Java developers take for granted, since 
it's been part of the mindset since very early days).

   - Dennis

On 06/14/2014 12:43 PM, Martin Buchholz wrote:
> http://channel9.msdn.com/Shows/Going+Deep/C-and-Beyond-2012-Herb-Sutter-Concurrency-and-Parallelism
>
>
> On Fri, Jun 13, 2014 at 4:35 PM, Dennis Sosnoski <dms at sosnoski.com 
> <mailto:dms at sosnoski.com>> wrote:
>
>     I'm writing an article where I'm discussing both blocking waits
>     and non-blocking callbacks for handling events. As I see it, there
>     are two main reasons for preferring non-blocking:
>
>     1. Threads are expensive resources (limited to on the order of
>     10000 per JVM), and tying one up just waiting for an event
>     completion is a waste of this resource
>     2. Thread switching adds substantial overhead to the application
>
>     Are there any other good reasons I'm missing?
>
>     On the thread switching issue, I tried a simple timing test where
>     I create some number of threads and have them take turns
>     incrementing a value, each one passing control off to the next
>     after an increment. For a total of 4096*100 increments here's what
>     I got on my 4-core AMD Linux desktop running Java 7:
>
>     Took 44 ms. with 1 threads
>     Took 3805 ms. with 2 threads
>     Took 6172 ms. with 4 threads
>     Took 6185 ms. with 8 threads
>     Took 6437 ms. with 16 threads
>     Took 6831 ms. with 32 threads
>     Took 6756 ms. with 64 threads
>     Took 6511 ms. with 128 threads
>     Took 6975 ms. with 256 threads
>     Took 7264 ms. with 512 threads
>     Took 7185 ms. with 1024 threads
>     Took 6826 ms. with 2048 threads
>     Took 7639 ms. with 4096 threads
>
>     So a big drop in performance going from one thread to two, and
>     again from 2 to 4, but after than just a slowly increasing trend.
>     That's about 19 microseconds per switch with 4096 threads, about
>     half that time for just 2 threads. Do these results make sense to
>     others?
>
>     Thanks,
>
>       - Dennis
>
>     _______________________________________________
>     Concurrency-interest mailing list
>     Concurrency-interest at cs.oswego.edu
>     <mailto:Concurrency-interest at cs.oswego.edu>
>     http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20140614/48189704/attachment.html>


More information about the Concurrency-interest mailing list