harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Ellison (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-6328) [classlib][nio] optimize SocketChannel.write(ByteBuffer[], int, int) by writev
Date Thu, 03 Sep 2009 09:06:32 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-6328?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12750925#action_12750925
] 

Tim Ellison commented on HARMONY-6328:
--------------------------------------

Good to see this enhancement!

A minor comment first :-)  Please check return values for :

+  vect = (struct iovec*) hymem_allocate_memory(sizeof(struct iovec) * length);
+
+  message = (*env)->GetPrimitiveArrayCritical(env, addrs, &isCopyMessage);
+  cts = (*env)->GetPrimitiveArrayCritical(env, counts, &isCopyCts);


A further enhancement is to have two versions of primitives, one that deals with direct buffers
and one that deals with java heap buffers, so that there is (potentially) no data copying
required for the java-heap buffers version that you have got today:

+            if (!buffer.isDirect()) {
+                src[i] = ByteBuffer.allocateDirect(buffer.remaining());
+                int oldPosition = buffer.position();
+                src[i].put(buffer);

some VMs will pin the java heap memory accessed in JNI (GetByteArrayElements), so if you can
get hold of the ByteBuffer#array() you can pass a set of pointers to the backing arrays and
maybe send the data directly.

Looking forward to seeing the readv impl too ;-)


> [classlib][nio] optimize SocketChannel.write(ByteBuffer[], int, int) by writev
> ------------------------------------------------------------------------------
>
>                 Key: HARMONY-6328
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6328
>             Project: Harmony
>          Issue Type: Improvement
>          Components: Classlib
>    Affects Versions: 5.0M11
>            Reporter: Regis Xu
>         Attachments: HARMONY-6328.diff, HARMONY-6328.v2.diff
>
>
> SocketChannel.write(ByteBuffer[], int, int) can be optimized by using writev, which can
write an array of buffer to socket without any stage buffer. If all passed in ByteBuffer is
direct buffer, they can be passed to system call directly without any copies.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message