New java.net Article: Reducing Contention and Overhead in Worker Queues
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.
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.
- Sonya Barry, Hello from South Carolina;
- Juliano Viana, GlassFish Webcast Series: Java EE 6 e GlassFish Server 3.1: Simplicidade + Leveza = Produtividade;
- Ed Burns, Jazoon 2011 Picks; and
- Alexander Potochkin, Swing in a better world: Listeners.
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.
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.
Here are the stories we've recently featured in our Java news section:
- Mark Lewis talks about Scala: The Static Language that Feels Dynamic;
- Andrew Binstock describes Making Large Classes Small (In 5 Not-So-Easy Steps);
- Giorgio Sironi presents Parallelism for dummies;
- Mark Reinhold announces the OpenJDK Community Bylaws: Final draft;
- Antonio Goncalves contributes to a [Debate] - And what about configuration in Java EE 7 ?;
- Adam Bien demonstrates How to Reuse Java EE 6 Code with Maven(3);
- Henrik St
Attachment Size worker_queue_fig4.gif 10.57 KB