Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 338442 - ExecutorThreadPool never grows above core size
Summary: ExecutorThreadPool never grows above core size
Status: RESOLVED INVALID
Alias: None
Product: Jetty
Classification: RT
Component: server (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 7.2.x   Edit
Assignee: Simone Bordet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-28 12:28 EST by Jan Prach CLA
Modified: 2011-04-01 11:36 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Prach CLA 2011-02-28 12:28:06 EST
Build Identifier: 7.3.0.v20110203

ExecutorThreadPool never grows above corePoolSize. It's supposed to grow up to maximumPoolSize, right?

It does not. When created with core size 8 and maximum size 100 - it process at most 6 requests at a time. It does not grow. (the other two threads are taken by acceptor or selector)

The workaround is simple - just set corePoolSize is to maximumPoolSize. But it's rather unfortunate to notice it in production :-)

Verified on:
 * linux - ubuntu lucid
 * sun jvm 6_u22, 6_u24
 * jetty 7.3.0.v20110203, 7.2.2.v20101205 and 7.1.6.v20100715

Reproducible: Always

Steps to Reproduce:
// pool
ThreadPool pool = new ExecutorThreadPool(3, 100, 60, TimeUnit.SECONDS);

// selector
SelectChannelConnector connector = new SelectChannelConnector();
connector.setThreadPool(pool);

// server
Server server = new Server();
server.addConnector(connector);

// try to send two requests in parallel
Comment 1 Greg Wilkins CLA 2011-03-31 23:52:30 EDT
Simone,

Can you take a look at this one as your such a big fan of the JVM thread pool :-)


Jan,

the Jetty Queued Thread pool has been demonstrated to have a lot better performance than the executor. 

cheers
Comment 2 Simone Bordet CLA 2011-04-01 08:53:40 EDT
The behavior reported is expected and it's documented in java.util.concurrent.ThreadPoolExecutor (http://download.oracle.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html), specifically in the section "Queuing".

While I admit it may be counter-intuitive, that's the JDK behavior, it is documented, and Jetty's ExecutorThreadPool just wraps JDK's ThreadPoolExecutor, so it inherits the behavior.

Specifically, from the Javadocs linked above:

"Using an unbounded queue (for example a LinkedBlockingQueue without a predefined capacity) will cause new tasks to wait in the queue when all corePoolSize threads are busy. Thus, no more than corePoolSize threads will ever be created. (And the value of the maximumPoolSize therefore doesn't have any effect.)"
Comment 3 Jan Prach CLA 2011-04-01 11:36:42 EDT
You're right! I'm going to read the javadocs better next time ;-)


Thanks,
Jan