public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Guenther <rguenther@suse.de>
To: Gabriel Dos Reis <gdr@integrable-solutions.net>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH][C++] Save memory and reallocations in name-lookup
Date: Fri, 17 Aug 2012 11:58:00 -0000	[thread overview]
Message-ID: <alpine.LNX.2.00.1208171353380.28649@zhemvz.fhfr.qr> (raw)
In-Reply-To: <CAAiZkiBd0oBcxkVw-S1TKvV=Bqy1Rs5s8eiD5zu_HBg4uHcA5g@mail.gmail.com>

On Fri, 17 Aug 2012, Gabriel Dos Reis wrote:

> On Fri, Aug 17, 2012 at 6:17 AM, Richard Guenther <rguenther@suse.de> wrote:
> >
> > This reduces the number of re-allocations and the amount of memory
> > wasted by store_binding.  Previously, on a cut-down testcase from
> > PR54146 we can see (--enable-gather-detailed-mem-stats -fmem-report
> > output):
> >
> > cp/name-lookup.c:5874 (store_binding)              12033504: 1.6%
> > 8564032: 2.4%          0: 0.0%    2398752:12.9%      30134
> >
> > that's the GC VEC (re-)allocation which wastes 2MB and re-allocates
> > 30134 times.  After the patch we have
> >
> > cp/name-lookup.c:5911 (store_bindings)              1243648: 0.2%
> > 352240: 0.1%          0: 0.0%     154064: 0.9%       9407
> > cp/name-lookup.c:5945 (store_class_bindings)        9643632: 1.3%
> > 120160: 0.0%          0: 0.0%     209376: 1.3%      10109
> 
> Nice saving.  As original author of the name lookup refactoring and improvement,
> I am delighted to see we can do much better.
> 
> I am however concerned with:
> 
> >   static void
> >   store_bindings (tree names, VEC(cxx_saved_binding,gc) **old_bindings)
> >   {
> > !   static VEC(tree,heap) *bindings_need_stored = NULL;
> 
> I would be more comfortable to see the cache be on per-scope
> (e.g. namespace scope) basis as opposed
> a blanket global cache stored in a global variable.

It's a "cache" only to not need a malloc/free for each store_bindings,
store_class_bindings invocation.  I've made it function local for
code cleaniness.  We're using this kind of trick elsewhere in the
compiler.

> > It seems we can end up with duplicates in the
> > names chain of store_bindings (not sure if that is intended).
>
> the chain is supposed to implement a stack, not a set.

Ah, I see.  That explains it.

Richard.

  reply	other threads:[~2012-08-17 11:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-17 11:20 Richard Guenther
2012-08-17 11:41 ` Gabriel Dos Reis
2012-08-17 11:58   ` Richard Guenther [this message]
2012-08-17 11:59   ` Jakub Jelinek
2012-08-17 12:46     ` Gabriel Dos Reis
2012-08-18  6:40     ` Dimitrios Apostolou
2012-08-20  7:24       ` Richard Guenther
2012-08-17 11:44 ` Gabriel Dos Reis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LNX.2.00.1208171353380.28649@zhemvz.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gdr@integrable-solutions.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).