Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 97073 invoked from network); 28 Sep 2007 19:24:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Sep 2007 19:24:14 -0000 Received: (qmail 62081 invoked by uid 500); 28 Sep 2007 19:24:04 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 62049 invoked by uid 500); 28 Sep 2007 19:24:04 -0000 Mailing-List: contact commits-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 commits@harmony.apache.org Received: (qmail 62037 invoked by uid 99); 28 Sep 2007 19:24:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Sep 2007 12:24:04 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Sep 2007 19:26:36 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 966E471420D for ; Fri, 28 Sep 2007 12:23:50 -0700 (PDT) Message-ID: <16601466.1191007430596.JavaMail.jira@brutus> Date: Fri, 28 Sep 2007 12:23:50 -0700 (PDT) From: "Aleksey Shipilev (JIRA)" To: commits@harmony.apache.org Subject: [jira] Updated: (HARMONY-4869) [classlib][nio][performance] Selector improvements: moving away from O(n) at Java layer, part 1 In-Reply-To: <4521034.1190909930977.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HARMONY-4869?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Aleksey Shipilev updated HARMONY-4869: -------------------------------------- Description: Current implementation of java.nio.channels.Selector is O(n) for Selector.select() operation. There are several causes: 1. "keys" is the HashSet, so we spend time on iterating over it 2. "keys" are iterated on every select() to prepare the readable and writable arrays for native call This patch includes a bunch of optimizations: 1. Creates hashCode() and equals() for SelectionKeyImpl to get rid of calling _native_ identityHashCode() 2. Changes the internal representation of keys to SelectionKeyImpl[] and adds logic for on-the-fly maintenance 3. Adds on-the-fly maintenance for readable and writable arrays, making them prepared right away for every select() 4. Adds indexes for easy mapping "keys<->FD" 5. Optimizes hotpath in processResults(). Keeping in mind that count(register) <= count(select), we sure that moving key set maintenance to register() is performance-safe. Thus, we simplify one part of Selector.select() call from being O(n) in the Java layer. There are also processResults() scales as O(n) and still portlib and native layers too - they're going to be optimized later too. was: Current implementation of java.nio.channels.Selector is O(n) for Selector.select() operation. There are several causes: 1. keys is the HashSet, so we spend time on iterating over it 2. keys are iterated on every select() to prepare the readable and writable arrays for native call This patch includes a bunch of optimizations: 1. Creates hashCode() and equals() for SelectionKeyImpl to get rid of calling _native_ identityHashCode() 2. Changes the internal representation of keys to SelectionKeyImpl[] and adds logic for on-the-fly maintenance 3. Adds on-the-fly maintenance for readable and writable arrays, making them prepared right away for every select() 4. Adds indexes for easy mapping of keys<->FD 5. Optimizes hotpath in processResults(). Keeping in mind that count(register) <= count(select), we sure that moving maintenance to register() is performance-safe. Thus, we simplify one part Selector.select() from being O(n) in the Java layer, not saying about processResults() - to be optimized later. Overall Selector.select() call is still O(n) because of portlib and native layers - to be optimized later too. > [classlib][nio][performance] Selector improvements: moving away from O(n) at Java layer, part 1 > ----------------------------------------------------------------------------------------------- > > Key: HARMONY-4869 > URL: https://issues.apache.org/jira/browse/HARMONY-4869 > Project: Harmony > Issue Type: Improvement > Components: Classlib > Environment: all > Reporter: Aleksey Shipilev > Attachments: selectors-JL-O1.patch > > > Current implementation of java.nio.channels.Selector is O(n) for Selector.select() operation. > There are several causes: > 1. "keys" is the HashSet, so we spend time on iterating over it > 2. "keys" are iterated on every select() to prepare the readable and writable arrays for native call > This patch includes a bunch of optimizations: > 1. Creates hashCode() and equals() for SelectionKeyImpl to get rid of calling _native_ identityHashCode() > 2. Changes the internal representation of keys to SelectionKeyImpl[] and adds logic for on-the-fly maintenance > 3. Adds on-the-fly maintenance for readable and writable arrays, making them prepared right away for every select() > 4. Adds indexes for easy mapping "keys<->FD" > 5. Optimizes hotpath in processResults(). > Keeping in mind that count(register) <= count(select), we sure that moving key set maintenance to register() is performance-safe. > Thus, we simplify one part of Selector.select() call from being O(n) in the Java layer. There are also processResults() scales as O(n) and still portlib and native layers too - they're going to be optimized later too. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.