[concurrency-interest] Blocking vs. non-blocking

Martin Buchholz martinrb at google.com
Fri Jun 13 20:43:38 EDT 2014


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> 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
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20140613/4d665a2b/attachment.html>


More information about the Concurrency-interest mailing list