Return-Path: X-Original-To: apmail-mahout-dev-archive@www.apache.org Delivered-To: apmail-mahout-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 071C0105A1 for ; Tue, 4 Feb 2014 00:08:35 +0000 (UTC) Received: (qmail 23063 invoked by uid 500); 4 Feb 2014 00:08:32 -0000 Delivered-To: apmail-mahout-dev-archive@mahout.apache.org Received: (qmail 23006 invoked by uid 500); 4 Feb 2014 00:08:32 -0000 Mailing-List: contact dev-help@mahout.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@mahout.apache.org Delivered-To: mailing list dev@mahout.apache.org Received: (qmail 22998 invoked by uid 99); 4 Feb 2014 00:08:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Feb 2014 00:08:32 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ted.dunning@gmail.com designates 209.85.160.176 as permitted sender) Received: from [209.85.160.176] (HELO mail-yk0-f176.google.com) (209.85.160.176) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Feb 2014 00:08:27 +0000 Received: by mail-yk0-f176.google.com with SMTP id 131so18138065ykp.7 for ; Mon, 03 Feb 2014 16:08:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=MmF9dhZsE3BBjXpKLNH5pZWSckXUC+6ahX5t+12BB+0=; b=e6I9/vI7sXet9/0V5r6owLRvdSm9gJlYAHwkiYBfF/VLvckXsL+UG/PZjbWE7B9F4T QiteB9IXkpv211F/mgMO5OaYYAtE6xowG5qhB9R/8DA2ZV+frcd3yIVASfXqWzsRItzF kaTAgSo0bpEwyjw7Bnv1obetEf+lp7SCimStkUGBQ2YaALEGW+FSeVhz//4ycckteHed DnF8p9XRmIWH6kkCHnagFDh4F0VMT747HitJ04DWXjO1Rtf7gw5E8yQExCGHgs29MZz8 Z1RLTinrJ12J0LXW6lmKfkaEfYAntwX27c2JGdrQaLFyrKT9c+GqVx1OQLcVqrC+KBIk uN8A== X-Received: by 10.236.221.167 with SMTP id r37mr3675564yhp.85.1391472486066; Mon, 03 Feb 2014 16:08:06 -0800 (PST) MIME-Version: 1.0 Received: by 10.170.125.22 with HTTP; Mon, 3 Feb 2014 16:07:35 -0800 (PST) In-Reply-To: References: From: Ted Dunning Date: Mon, 3 Feb 2014 16:07:35 -0800 Message-ID: Subject: Re: Optimization of AbstractLogisticRegression.regularize? To: Mahout Dev List Content-Type: multipart/alternative; boundary=001a11c2ddae3f2e6f04f1896fa2 X-Virus-Checked: Checked by ClamAV on apache.org --001a11c2ddae3f2e6f04f1896fa2 Content-Type: text/plain; charset=UTF-8 Optimization of this kind is definitely worthwhile, but 10% improvements probably are a bit small. Your difficulty in reproducing the results indicates how ephemeral small improvements can be. If you find a 2x difference, however, we should definitely talk. It isn't too surprising that inverting loops might make a difference since it makes a big difference in matrix multiplication as well. I would worry a bit about iterating over categories first because that changes the heart of the algorithm. If setQuick by itself made a big difference, I might consider doing it, but I would also expect set to get inlined before long and optimized into a simple setQuick call. One of the biggest places to make a serious dent would be in the text processing that is done in a few places. I have seen gains of 10x over naive code that is simply blasting through text or CSV. If you come up with a clean and easy to use DFA implementation of that, then it would make a significant difference. Beyond that, math library speedups are always welcome. For instance, having an extension that offers JBLAS matrices and vectors would be cool for some applications. On Mon, Feb 3, 2014 at 12:53 PM, Frank Scholten wrote: > Hi all, > > I profiled the AbstractLogisticRegression.regularize() method with > JVisualVM and I could reduce the CPU time by 10% by a doing the following: > > * Using setQuick() instead of set() > * Switching the isSealed() and updateSteps == null check > * Computing lambda * learningRate outside of the loop > * Iterating over the categories first and over elements second > > I like to experiment a bit more on performance tuning and looking at > HotSpot and such because I am not sure why certain changes made the > improvements. Does anyone know how to go from here, in terms of which tools > to use and what kind of approach to take? > > Also, is this optimization even worth it or perhaps there are other areas > more important in Mahout to optimize? I just ran VisualVM again and now it > isn't at the top of profiler anymore, now it is > FeatureVectorEncoder.bytesForString() > > Cheers, > > Frank > --001a11c2ddae3f2e6f04f1896fa2--