Swap should be better done native?

Ulf Zibis Ulf.Zibis at gmx.de
Thu Apr 1 17:32:12 PDT 2010


Am 01.04.2010 09:35, schrieb Martin Buchholz:
> After looking a bit at the buffer implementation,
> it seems like direct buffers optimize multibyte
> operations like putInt using Unsafe.
>
> Is this true?
>
> If so, why can't non-direct buffers (HeapByteBuffers)
> do that as well, by using the object-based versions
> of Unsafe operations?
>
> If we could make such an optimization for non-direct
> buffers, it would be a huge performance gain for some
> uses.

Yes, it seems that in some cases, e.g. EUC_TW where putInt(int) could 
replace 4 put(byte), the direct buffers run as fast or faster than the 
heap buffers.

-Ulf




More information about the nio-discuss mailing list