Return-Path: X-Original-To: apmail-tomcat-dev-archive@www.apache.org Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0812110183 for ; Tue, 4 Mar 2014 19:23:45 +0000 (UTC) Received: (qmail 91208 invoked by uid 500); 4 Mar 2014 19:23:39 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 90980 invoked by uid 500); 4 Mar 2014 19:23:38 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 90612 invoked by uid 99); 4 Mar 2014 19:23:37 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Mar 2014 19:23:37 +0000 Received: from localhost (HELO mail-oa0-f52.google.com) (127.0.0.1) (smtp-auth username remm, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Mar 2014 19:23:37 +0000 Received: by mail-oa0-f52.google.com with SMTP id l6so6676439oag.25 for ; Tue, 04 Mar 2014 11:23:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=4ToYwgmRYEbF7x/LbCwJmUnUjY+VgukytPjZRPoxVIs=; b=FRR+TYjpBfo+ykwIFwAa6Qu9B7LV3RDFic6rJZ53JvnmbfTKMJqmdXhEHJ/zm6bT/j RQMKufC2IiJu7MrtQuPTvbXyssQmcD6oKSmZhccdP291DrCg3Pfe6BWilIIZUmTLgT57 ejWYZHw4fXHdydVBWU6KrzCbUqTGuMaxRo8rd5YolhhrtpyL99MPuEXuCMii3E61cJKX EHuGMDOjv8Imek+DhMu9ZASkE9TAJBPD4ODmIwMypws8VQNkTxG5mId2icCyTTu43kyU U87Z/xEzerarY4W4GQb3ELiBsKLtlp8Sz0aN0ukNFo4GGDMKyD6czBb01r52pj+746VK odtg== MIME-Version: 1.0 X-Received: by 10.182.107.232 with SMTP id hf8mr975098obb.75.1393961016350; Tue, 04 Mar 2014 11:23:36 -0800 (PST) Received: by 10.76.74.133 with HTTP; Tue, 4 Mar 2014 11:23:36 -0800 (PST) In-Reply-To: <53161ADC.9070400@apache.org> References: <53161ADC.9070400@apache.org> Date: Tue, 4 Mar 2014 20:23:36 +0100 Message-ID: Subject: Re: NIO 2 connector From: =?ISO-8859-1?Q?R=E9my_Maucherat?= To: Tomcat Developers List Content-Type: multipart/alternative; boundary=089e013c6f9c35e49b04f3ccd762 --089e013c6f9c35e49b04f3ccd762 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 2014-03-04 19:26 GMT+01:00 Mark Thomas : > On 04/03/2014 16:16, R=E9my Maucherat wrote: > > Hi, > > > > I've been working on porting a NIO2 connector that was originally > developed > > for JBoss AS by Nabil Benothman (an intern at Red Hat). Due to the very > > different connector structure in Tomcat and my preference for basing it > on > > the existing NIO1 connector, it is mostly new code, though. > > There looks to be opportunities to share code with the current NIO > connector. > Don't know. I used the structure, but the algorithms are quite different. You'll have the opportunity to do it if you want of course ;) > > There are some changes to the existing code, such as > java/org/apache/coyote/http11/upgrade/AbstractServletInputStream.java > that I would like to understand. > Nothing special, it needs a first read to start its "polling", so that's the reason for adding isReady() (normally harmless). I added the third event method too for consistency, and that's it. > > > So I would now like to contribute this in trunk as a new experimental > > connector. It should have feature parity with the NIO1 connectors. Of > > course, while the basics are in, it will need some time to pass the > > testsuite, fix issues, improve stability, etc. > > Can you wait until we split 8.0.x from trunk or did you want to get this > into 8.0.x? > Depends, if you want to branch soon or not. It would have to be experimental for a while anyway, but it will likely bring something useful. > > > Coyote version number could be moved up to 2.0 with this addition along > > with all the connector refactorings that Mark did in trunk. > > I'd rather drop the version number entirely as it is pretty much > meaningless. If we are going to do that, we may as well change the > server header to "Apache Tomcat". I'm neutral on whether to include the > major or full version number. > I think the spec says there should be a /0.0 version number, and I like the Coyote name, but you can change it. > > > The code is there (rebased to the current trunk): > > https://github.com/rmaucher/tomcat > > > > A quick NIO2 (the API) presentation. > > > > Pros: > > - Significantly faster, although the API looks slower by design > > - Resources friendly > > - Seemingly trivial to use > > - Polling is neatly hidden away > > - Thread pool is also neatly hidden away > > - Per operation timeouts > > - Read/Write is symmetric > > - Trivial blocking IO > > > > Cons: > > - No real non blocking IO > > Hmm. I was considering dropping the BIO connector entirely for Tomcat 9 > because of its inability to do non-blocking IO and the way the Servlet > API was heading. Does it make sense to add a different non-blocking > connector implementation or have I misunderstood your point? > Well, nobody is going for non blocking IO, people are using async IO. But then obviously the read(ByteBuffer) call which used to return an int (possibly 0 with non blocking IO) now returns a Future. And if you want to know the result you have to wait for it and there's an IO operation pending the entire time. So that's the "cons". It would be nice to have non blocking operations for "peek" scenarios. So instead to peek a read, you have to read with a completion handler, then see if it returns inline. And if it doesn't there's an async process now doing IO (possibly not the greatest thing that could happen). > > > - No concurrency allowed [for the socket impl of NIO2] although the API > > looks concurrent > > Do you mean no concurrent read and writes? That would be a huge issue. > No, don't worry, that works. It's concurrency on the same operation (like read, write, accept). The API looks relatively magic, so you'd think you could do it. > > > - Simplicity is sometimes misleading, the API doesn't provide some tool= s > > for the needed synchronization, check pending operations and their > possible > > optimizations > > - SSL is not integrated any better than with NIO1, it is still SSLEngin= e > > which leads to creating the obligatory "AsynchronousSSLSocketChannel" > > wrapper class yourself > > - No real sendfile > > > > Comments ? > > The pros look nice but I am worried about the cons. > > The summary is that in the worst case, it's much better. R=E9my --089e013c6f9c35e49b04f3ccd762--