public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/96197] Excess memory consumption, positive correlation with the size of a constexpr array
Date: Wed, 15 Jul 2020 06:29:43 +0000	[thread overview]
Message-ID: <bug-96197-4-XL3zITBrtu@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-96197-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96197

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-07-15
      Known to fail|                            |10.1.0, 11.0
           Keywords|                            |memory-hog

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Does it help if you replace your simplistic O(n) algorithms with O(log n) ones?
That is, 

constexpr const struct word_type &WORD_LOOKUP(WORD index, const struct
word_type *table_row =word_table) {
    for (;;) {
        if (table_row->index == index) return *table_row;

        if (table_row->index == WORD::NONE) return word_lookup(WORD::NONE);

        ++table_row;
    }

//    return table_row->index == index ? *table_row : (table_row->index ==
WORD::NONE ? word_lookup(WORD::NONE) : WORD_LOOKUP(index, ++table_row));
}

replace the for (;;) loop with table_row[index] (OK, that's maybe too much
guessing into your data structure) or with a binary search over the table
which you keep sorted?

It's probably simply garbage that accumulates during constexpr evaluation.
-ftime-report shows

 constant expression evaluation     :  28.45 ( 92%)   1.57 ( 96%)  32.97 ( 92%)
5127882 kB (100%)

that is 5GB of GC memory from constexpr evaluation.

  reply	other threads:[~2020-07-15  6:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-14 15:30 [Bug c++/96197] New: " hyena at hyena dot net.ee
2020-07-15  6:29 ` rguenth at gcc dot gnu.org [this message]
2020-07-15  8:47 ` [Bug c++/96197] " hyena at hyena dot net.ee
2020-07-15  9:10 ` rguenther at suse dot de
2020-07-15  9:42 ` hyena at hyena dot net.ee
2020-07-21 16:17 ` ppalka at gcc dot gnu.org
2020-07-21 19:49 ` tridacnid at gmail dot com
2020-07-31  2:29 ` cvs-commit at gcc dot gnu.org
2020-07-31 13:51 ` ppalka at gcc dot gnu.org
2021-01-09  3:52 ` cvs-commit at gcc dot gnu.org
2021-01-09  3:54 ` ppalka at gcc dot gnu.org
2021-01-09  3:58 ` ppalka at gcc dot gnu.org
2021-01-18 15:39 ` ppalka at gcc dot gnu.org

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-96197-4-XL3zITBrtu@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).