Affects Version/s: 1.1.6, 2.0.0-M1
Fix Version/s: None
I benchmarked Mina 2.0's NioDatagramConnector vs java.net.DatagramSocket on a Linux 2.6 kernel.
Mina 2.0 NioDatagramConnector, connect(), future.addListener(), session.close()
~5,000 per second
java.net.DatagramSocket, connect(), disconnect(), close()
~30,000 to 50,000 per second
I believe the basic problem is that AbstractPollingIoConnector/AbstractPollingIoProcessor assumes that connecting a UDP datagram socket should be a scheduled operation. For TCP, this makes a lot of sense as connect() should be an asynchronous operation.
But for UDP, where connect() only performs kernel resource reservation, it makes more sense I think to connect immediately and return an IoFuture with the IoSession already connected and ready. Looking at the code, I see that the connect() call is indeed made on the same call stack, but ConnectFuture.setSession() is executed by the AbstractPollingIoProcessor worker thread after the IoSession has been properly registered.