On 24 Apr 2012, at 12:25, Manik Surtani wrote:
On 24 Apr 2012, at 09:25, Mircea Markus wrote:
>>
>> The reason I ask is that at some point we should look at not only an NIO impl (I
know you had one that you experimented with some while back) but also a JDK7 NIO2 one, and
benchmark the three.
>
> Agreed. I'd expect an NIO/NIO2 client to handle much better the async requests
from client to the server than the current IO client which is optimised for sync
operations.
I was just wondering because the entire stack could be async, all the way from API call
to network transport, and the network future appropriately wrapped and returned as a
return value to the client. If a sync API is called, just delegate to the async operation
and call get() once on the compound future. Should make for a very clean and high
performance client.
With NIO the async path should be faster indeed, but would
affect the sync path as there would be a point in which client threads are blocked waiting
for the transport thread (inter thread com). Instead of waiting they could do the work
interaction themselves and avoid the passing of requests/responses for one thread to the
other.
Performance wise, I don't think NIO would overtake IO for for *sync* calls but it
will for *async* calls. Also code wise, I don't think it would be simpler, just
because of NIO's model and inter thread communication. But I think a NIO client would
be of interest especially when using the clients in async mode. And performance wise for
sync clients - we might see different numbers than what I expect.