public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c++: cache conversion function lookup
Date: Thu, 7 Sep 2023 17:34:51 -0400	[thread overview]
Message-ID: <5142c5ec-2b9b-e3f7-d852-848f84d36155@redhat.com> (raw)
In-Reply-To: <2ee308f7-f36e-59f9-94d6-e805034fbba4@idea>

On 9/7/23 16:12, Patrick Palka wrote:
> On Thu, 7 Sep 2023, Jason Merrill wrote:
> 
>> On 9/6/23 18:07, Patrick Palka wrote:
>>> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for
>>> trunk?  This cache apparently has a 98% hit rate for TYPE_HAS_CONVERSION
>>> types on some test files.
>>
>> Does it make a measurable difference in compile time?
> 
> Admittedly this optimization was probably more justified with the older
> version of the PR99599 patch that added another lookup_conversions call.
> Compile time for this standalone patch in the noise according to my
> experiments, but I did measure a ~1MB/0.2% decrease in memory usage for
> range-v3's zip.cpp.  This is because lookup_conversions_r allocates a
> new list each time it's called (on a TYPE_HAS_CONVERSION type) even in
> the simple case of no inheritance etc.  Maybe lookup_conversions_r's
> (relatively complicated) implementation could be improved in the
> simple/common case...
> 
>>> +/* A cache of the result of lookup_conversions.  */
>>> +
>>> +static GTY((cache)) type_tree_cache_map *lookup_conversions_cache;
>>
>> This should probably be (deletable) rather than (cache)?
> 
> Ack.  Is that because of PCH concerns or because the cache is
> purely an optimization and so has no semantic effect?

The latter.  Really, (cache) is a terrible name, it should only be used 
when it's impractical to recompute the value.

Jason


      reply	other threads:[~2023-09-07 21:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-06 22:07 Patrick Palka
2023-09-07 19:18 ` Jason Merrill
2023-09-07 20:12   ` Patrick Palka
2023-09-07 21:34     ` Jason Merrill [this message]

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=5142c5ec-2b9b-e3f7-d852-848f84d36155@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ppalka@redhat.com \
    /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).