From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 63586 invoked by alias); 22 Aug 2018 17:43:49 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@gcc.gnu.org Received: (qmail 63567 invoked by uid 89); 22 Aug 2018 17:43:49 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2536 X-HELO: mail-pf1-f173.google.com Received: from mail-pf1-f173.google.com (HELO mail-pf1-f173.google.com) (209.85.210.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 22 Aug 2018 17:43:47 +0000 Received: by mail-pf1-f173.google.com with SMTP id j26-v6so1305831pfi.10; Wed, 22 Aug 2018 10:43:47 -0700 (PDT) Return-Path: Received: from andrew-precision-3520.localnet (pool-239.obs.carnegiescience.edu. [192.91.178.239]) by smtp.gmail.com with ESMTPSA id v19-v6sm8122579pgn.94.2018.08.22.10.43.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Aug 2018 10:43:44 -0700 (PDT) From: Andrew Benson To: Thomas Koenig Cc: "fortran@gcc.gnu.org" , gcc-patches Subject: Re: Optimization in load_generic_interfaces() Date: Wed, 22 Aug 2018 17:43:00 -0000 Message-ID: <2743702.IuEFOsNmPT@andrew-precision-3520> User-Agent: KMail/5.2.3 (Linux/4.4.0-131-generic; KDE/5.36.0; x86_64; ; ) In-Reply-To: References: <2839679.PxYyRMJBjJ@andrew-precision-3520> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-IsSubscribed: yes X-SW-Source: 2018-08/txt/msg00092.txt.bz2 Hi Thomas, I have my sourceware account active now, so I should be able to commit this myself. I'll do so right away. Thanks, Andrew On Wednesday, August 22, 2018 5:43:30 PM PDT Thomas Koenig wrote: > Hi Andrew, > > [please also copy in gcc-patches for patches] > > > I'm continuing to look for optimizations to improve compile times for > > files > > which USE large numbers of modules containing large numbers of symbols. > > > > When the number of symbols becomes very large, find_symbol() becomes a > > slow- point, because it can't use the structure of the balanced binary > > tree to rapidly search the symtree, so just has to go through the whole > > tree until it finds (or doesn't find) the symbol. > > > > I don't see a simple way to improve the speed of this function, but there > > seems to be a simple change in load_generic_interfaces() which gives > > significant speed up: > > > > Index: gcc/fortran/module.c > > =================================================================== > > --- gcc/fortran/module.c (revision 263667) > > +++ gcc/fortran/module.c (working copy) > > @@ -4559,9 +4559,6 @@ load_generic_interfaces (void) > > > > /* Decide if we need to load this one or not. */ > > p = find_use_name_n (name, &i, false); > > > > - st = find_symbol (gfc_current_ns->sym_root, > > - name, module_name, 1); > > - > > > > if (!p || gfc_find_symbol (p, NULL, 0, &sym)) > > > > { > > > > /* Skip the specific names for these cases. */ > > > > @@ -4570,6 +4567,9 @@ load_generic_interfaces (void) > > > > continue; > > > > } > > > > + st = find_symbol (gfc_current_ns->sym_root, > > + name, module_name, 1); > > + > > > > /* If the symbol exists already and is being USEd without being > > > > in an ONLY clause, do not load a new symtree(11.3.2). */ > > > > if (!only_flag && st) > > > > This just delays the call to find_symbol() until after the first test of > > whether the symbol needs to be loaded - if that test fails then > > find_symbol() is never called. > > > > This has no significant effect on compile time for files which import > > small > > numbers of symbols. But for cases where the number is large I find that > > the > > compile time can be reduced by up to 40% in the cases I've tried. > > > > The change passes all regression tests cleanly. > > The patch is OK for trunk. > > Thanks! > > Regards > > Thomas -- * Andrew Benson: http://users.obs.carnegiescience.edu/abenson/contact.html * Galacticus: https://bitbucket.org/abensonca/galacticus