Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 23571 invoked from network); 6 Sep 2009 13:19:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 6 Sep 2009 13:19:56 -0000 Received: (qmail 35791 invoked by uid 500); 6 Sep 2009 13:19:55 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 35721 invoked by uid 500); 6 Sep 2009 13:19:55 -0000 Mailing-List: contact dev-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list dev@harmony.apache.org Received: (qmail 35710 invoked by uid 99); 6 Sep 2009 13:19:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Sep 2009 13:19:55 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of clraychen@gmail.com designates 209.85.210.188 as permitted sender) Received: from [209.85.210.188] (HELO mail-yx0-f188.google.com) (209.85.210.188) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Sep 2009 13:19:45 +0000 Received: by yxe26 with SMTP id 26so187999yxe.20 for ; Sun, 06 Sep 2009 06:19:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=LTCAYvnL4ABOOsJSRTc1i7Am/b6A5nZcyxFpuvDUR70=; b=E73XWeL1Ji16N6IQAXiEJV5QtDd2GVxdp7bRUZTpmV3Yz9Y8rVU1y9gpoQztt79P4X /MwqcH6DNcpJiFMYziusvnTTBGGHquvrrziC7BLROrjTiE9Ny92cIfvmO1AWPce/As7m zUXgSGPbVwEUJgCdQIBoK/9DpGwhGwskGkTqU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=omT5aQ3jC5V1P4su058fMvZB3oAAvA/NjWiynA5+yQanB/vunsdVU5YLfEGjNfYqa1 FvaqvrJeoJ5ra69+aAQkKBj0spSHSeYNN90qa6Co6jh59c2Ny/H0jJSoETDwOIObXX0B R3BxclHBT3D4WZPqdhUaC9InlaAChPYx3lYD0= MIME-Version: 1.0 Received: by 10.100.74.21 with SMTP id w21mr6798302ana.165.1252243164714; Sun, 06 Sep 2009 06:19:24 -0700 (PDT) In-Reply-To: <4A9FA881.5020402@gmail.com> References: <290644005.1251857072710.JavaMail.jira@brutus> <4A9F8871.4020605@gmail.com> <4A9F9976.7010003@gmail.com> <4A9FA881.5020402@gmail.com> Date: Sun, 6 Sep 2009 21:19:24 +0800 Message-ID: <4d9fb1a00909060619m41bf348du2130841d19656075@mail.gmail.com> Subject: Re: [jira] Created: (HARMONY-6328) [classlib][nio] optimize SocketChannel.write(ByteBuffer[], int, int) by writev From: Ray Chen To: dev@harmony.apache.org Content-Type: multipart/alternative; boundary=001636b2b0c60159480472e895f4 X-Virus-Checked: Checked by ClamAV on apache.org --001636b2b0c60159480472e895f4 Content-Type: text/plain; charset=ISO-8859-1 Hi Reigs, I have tested your patch on z/OS, it works OK. Greate job. On Thu, Sep 3, 2009 at 7:29 PM, Regis wrote: > Tim Ellison wrote: > >> 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); >> > > Yes, will add it, thanks. > > >> >> 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: >> > > One case stop me to do that is a buffer array contains direct and java heap > buffers both. In this case, either copying java heap buffres to direct > buffers or passing the whole array to native directly. > > If pass the array to native directly, it need to call isDirect and > AddressUtil.getDirectBufferAddress in native code, as I understand, call > java methods from native side is like reflection, even more expensive, so I > chose copying all java heap buffers to direct buffers, at least it fast when > most buffers are direct and size of java heap buffers are not too big. > > One possible solution I can think is adding a new native call > > writevDirect(JNIEnv *env, jobject thiz, jobject fd, jobject bufferArray, > jobject addrs, jobject counts, jint length) > > passing buffer array and native addresses of direct buffers together, if > element of addrs is 0, the corresponding buffer is not direct. Well, this > method is a little bit hard to understand, it has 7 parameters.... > > >> + 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 ;-) >> > > Sure, it's on my TODO list :) > > >> Regards, >> Tim >> >> >> > > -- > Best Regards, > Regis. > -- Best Regards, Ray Chen --001636b2b0c60159480472e895f4--