Skip to main content

New java.net Article: Reducing Contention and Overhead in Worker Queues

Posted by editor on June 15, 2011 at 7:31 PM PDT

We've just published a new article on java.net: "A Method for Reducing Contention and Overhead in Worker Queues for Multithreaded Java Applications" by Sathiskumar Palaniappan, Kavitha Varadarajan, and Jayashree Viswanathan. The article addresses the problem of writing code that efficiently utilizes the resources of modern multicore processors and multiprocessor servers. The introduction sets the scene:

Many server applications, such as Web servers, application servers, database servers, file servers, and mail servers, maintain worker queues and thread pools to handle large numbers of short tasks that arrive from remote sources. In general, a "worker queue" holds all the short tasks that need to be executed, and the threads in the thread pool retrieve the tasks from the worker queue and complete the tasks.

Since multiple threads act on the worker queue, adding tasks to and deleting tasks from the worker queue needs to be synchronized, which introduces contention in the worker queue. This article explains the contention involved with the traditional approach (using a common queue for the thread pool) and helps you reduce the contention by maintaining one queue per thread. This article also explains a work stealing technique that is important for utilizing the CPU effectively in multicore systems.

Sathiskumar, Kavitha, and Jayashree provide detailed description of the concepts; illustrations that depict the relationships and working of threads, tasks, and worker queues; along with example code. The article builds to a performance comparison between the Type 1 and Type 3 queues that are discussed in the article using benchmark code examples.

In conclusion:

This article demonstrated the contention involved in the common worker queue approach and then isolated the contention by creating one queue per thread. This article also demonstrated, through a simple benchmark, why work stealing is important and how it improves the overall performance of an application.

If you'd like to learn about more advanced techniques for efficiently utilizing the capabilities of modern multicore/multiprocessor systems, "A Method for Reducing Contention and Overhead in Worker Queues for Multithreaded Java Applications", by Sathiskumar Palaniappan, Kavitha Varadarajan, and Jayashree Viswanathan, is an article you'll want to read.


java.net Weblogs

Since my last blog post, there have been several significant java.net blogs composed by others:


Poll

Our current java.net poll asks "Do you intend to experiment with the JavaFX 2.0 Beta Release?" Voting will be open until Friday, June 24.


Articles

Our latest java.net article is "A Method for Reducing Contention and Overhead in Worker Queues for Multithreaded Java Applications", by Sathiskumar Palaniappan, Kavitha Varadarajan, and Jayashree Viswanathan.


Java News

Here are the stories we've recently featured in our Java news section:


Spotlights

Our latest java.net href="http://www.java.net/archive/spotlight">Spotlight is Java Spotlight Episode 34: Chuck Munn Lee on Using PhoneME on Nintendo DS:

Interview with Chuck Mun Lee, Java Evangelist, on porting PhoneME to Nintendo DS. Joining us this week on the Java All Star Developer Panel are Dalibor Topic, Java Free and Open Source Software Ambassador, and Alexis Moussine-Pouchkine, Java EE Developer Advocate...

We're also featuring the announcement from the Java Source, Duke's Choice Awards Open for Nominations:

Duke's Choice Awards are now open for nominations! For the ninth year running, we are looking for most compelling implementations of Java technology. Duke's Choice Awards are part of the Oracle Excellence Awards, Java Innovation 2011 program. Winners get a Duke statue, a free JavaOne full conference pass, and their winning implementation will be showcased at JavaOne. Winners are announced at JavaOne. Deadline for submission is Friday, July 22, 2011 @ 5:00 p.m. PT...


Subscriptions and Archives: You can subscribe to this blog using the java.net Editor's Blog Feed. You can also subscribe to the Java Today RSS feed and the java.net blogs feed. You can find historical archives of what has appeared the front page of java.net in the java.net home page archive.

-- Kevin Farnham

Twitter: @kevin_farnham

AttachmentSize
worker_queue_fig4.gif10.57 KB

Comments

<p>I maintain four Fork-Join frameworks on SourceForge.net ...

I maintain four Fork-Join frameworks on SourceForge.net so your article is of primary interest to me; thank you for taking the time and effort to produce your article and code.

However, (don't you hate that word) there are much better solutions.

TymeacSE (Fork-Join Development in Java SE -- http://coopsoft.com/ar/ForkJoinArticle.html) uses a multi-thread per queue approach. A j.u.c.ConcurrentLinkedQueue provides the contention-limiting base. With highly efficient thread management, this professional framework can handle huge numbers of concurrent requests.

TymeacDSE (A Java Fork-Join Conqueror -- http://coopsoft.com/ar/ConquerArticle.html) uses a single thread per queue approach since it supports dynamic task forking. Once again, a j.u.c.ConcurrentLinkedQueue provides the contention-limiting base and with efficient thread management, this professional framework can handle thousands of CPU/cores. Work-sharing is a far superior method then work-stealing in application services (as the article explains.) Doug Lea puts forth a Fork-Join framework for Java 1.7 using work-stealing, but that product is truly awful. (A Java Fork-Join Calamity -- http://coopsoft.com/ar/CalamityArticle.html)

Ed Harned

<p>Great article!</p>

Great article!