Perhaps we can open a JIRA to ask such that by default
MINA uses Runtime.getRuntime().availableProcessors();
to determine the number of Processors with a lower limit
for example as 16 Threads as now and uses this value
to create any Thread Pool by default with this
computed value ?
What do you think ?
Just to continue on my previous mail
however, I was thinking that the SocketAcceptor
has 16 threads by default but when I look into
the code :
public SocketAcceptor()
{
this( 1, new NewThreadExecutor() );
}
only one thread is used...
The default 16 threads is only for the default ExecutorFilter.
It could be something like (if Mina keep 1 thread by cpu) :
public SocketAcceptor()
{
int nbProc = Runtime.getRuntime().availableProcessors();
if (nbProc == 1)
this( 1, new NewThreadExecutor() );
else {
Executor executor = Executors.nexFixedThreadPool(nbProc);
this( nbProc, executor ) ;
}
}
And for how to set up a new Thread Pool, I think
I eventually understand better how to do (according to the API) :
Executor executor = Executors.nexFixedThreadPool( nb );
IoAcceptor acceptor = new SocketAcceptor();
ExecutorThreadModel execmodel =
ExecutorThreadModel.getInstance( mynameofpool );
execmodel.setExecutor( executor );
since the API says :
"It is strongly recommended to set a new ExecutorThreadModel by calling
ExecutorThreadModel#getInstance(String)."
Frederic
--------------------------------------------------------
> When reading this thread I 'm thinking that mina should have a method
> somewhere that would define the number of cpus/cores of the underlying
> system. For example: xxxx.setCpuNumber(2);
>
> From that only setting, wouldn't mina have enough information to
> configure itself optimally?
You can already get this from the Java runtime:
Runtime.getRuntime().availableProcessors();
We use this to configure various bits of Qpid, e.g.
https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid/java/common/src/org/apache/qpid/pool/ReferenceCountingExecutorService.java
RG