public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jimis at gmx dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug preprocessor/53525] Performance regression due to enabling track-macro-expansion
Date: Mon, 04 Jun 2012 04:49:00 -0000	[thread overview]
Message-ID: <bug-53525-4-bftd4JZUzS@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-53525-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53525

jimis <jimis at gmx dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #27520|0                           |1
        is obsolete|                            |
  Attachment #27523|0                           |1
        is obsolete|                            |

--- Comment #13 from jimis <jimis at gmx dot net> 2012-06-04 04:49:13 UTC ---
Created attachment 27550
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27550
Diff of all changes versus the 20120513 snapshot.

I think I'm closing to a final version of this fix. The attached patch contains
all of the above mentioned changes, plus it fixes the memory leaks. This
bootstraps fine and passes tests on x86 with no regression. 

Instruction count has been reduced from 2201M downto 2108M, which is only 30M
higher than having track-macro-expansion (TME) turned off. Unfortunately actual
runtime was improved less, so we gained back almost 50% of what we had lost by
enabling TME. In short running the same test as above, with this (macro5)
patch, gives:

2108 M instr
31692 KB RAM
0.760s

In a few words, I introduced four (!) new obstacks inside struct cpp_reader for
allocating the tokens from macro argument expansion, their virtual locations,
the virtual locations of arguments, and the virtual locations of other macros. 

I'm not sure whether this is an elegant solution but growing obstacks for
nested scopes is much more intuitive than reallocating arrays. I'd appreciate
any comments on my "TODO" notes in this patch, which mostly concern whether I
should move other allocations to obstacks as well.

Finally, my patch still contains the additions to obstacks (obstack_mark,
obstack_release). I'll try submitting them to glibc but since they are in the
obstack.h header file, they work even when using the libc obstacks so I guess
they can be committed in the gcc tree.


  parent reply	other threads:[~2012-06-04  4:49 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-30  4:04 [Bug preprocessor/53525] New: " jimis at gmx dot net
2012-05-30  4:24 ` [Bug preprocessor/53525] " jimis at gmx dot net
2012-05-30  4:52 ` jimis at gmx dot net
2012-05-30  5:24 ` jimis at gmx dot net
2012-05-30  5:28 ` jimis at gmx dot net
2012-05-30  5:31 ` jimis at gmx dot net
2012-05-30  6:02 ` jimis at gmx dot net
2012-05-30  6:06 ` jimis at gmx dot net
2012-05-30  6:10 ` jimis at gmx dot net
2012-05-30  6:24 ` jimis at gmx dot net
2012-05-30  6:25 ` jimis at gmx dot net
2012-05-30  8:38 ` rguenth at gcc dot gnu.org
2012-05-30 16:04 ` jimis at gmx dot net
2012-06-04  4:49 ` jimis at gmx dot net [this message]
2012-06-27 22:59 ` jimis at gmx dot net
2012-06-28  9:53 ` rguenth at gcc dot gnu.org
2013-06-13 15:59 ` mathias at gaunard dot com
2013-06-13 20:55 ` manu at gcc dot gnu.org
2013-07-09 12:43 ` mathias at gaunard dot com

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=bug-53525-4-bftd4JZUzS@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).