"이희승 (Trustin Lee <[EMAIL PROTECTED]> writes: > Emmanuel Lecharny wrote: > It seems like the hotspot engine optimizes the test(...) method to work > better with a certain type of byte buffer. I inlined the test(...) > method into the two test methods, and now I am getting consistent > result. Direct buffer outperforms heap buffer for all cases in Java 6, > except for the allocation and deallocation. If we can provide > reasonable solution for pooling direct buffers, we will be able to gain > more performance out of MINA. > > BTW, it is interesting that direct buffer outperforms heap buffer. > Kudos to the JVM developers!
Hi! I did some testing just a while back. I got similar results and read the javadoc more carefully, which states some points about "direct" buffers: - They are expensive to create. - They can prevent that a java byte buffer is copied to a native array/buffer in an IO-Operation. "It is therefore recommended that direct buffers be allocated primarily for large, long-lived buffers that are subject to the underlying system's native I/O operations." Your test is therefore missing some "IO action" where a direct/heap buffer can do it's tricks. Mina is an IO-Framework, so there may be some places that will perform better with direct buffers and some places where a pure java buffer does. The question is: How much can you increase performance with tweaking the buffers without harming the performance in some worst case scenarios (i.e. small messages vs. big messages).
