From: Mandeep Sandhu <mandeepsandhu.chd@gmail.com>
To: gcc-help@gcc.gnu.org
Subject: stdc++ issue: extremely long compile time with large number of string literals
Date: Thu, 9 Jul 2020 13:31:41 -0700 [thread overview]
Message-ID: <CAC+QLdSAw2sxrbAd4tS52_BtL22mTfUTBAGD2eohxFw6vNM+SA@mail.gmail.com> (raw)
Hi All,
I have an strange (to me) issue, where trying to compile a header
which has a single "std::unordered_set<std::string>" initialized with
around 50K short strings is taking forever.
The set is declared as:
const std::unordered_set<std::string> my_set ({"item1", "item2", ....});
(The header is auto-generated using a script which takes a JSON array
and puts its elements in an unordered_set)
I understand that creation of many strings has an overhead, but this
issue seems to affect compilation time, not runtime.
Can someone explain to me why it takes such a long time to compile?
Keeping the strings to under 5K, makes the program compile in about 8
secs.
I'm using the following compiler on Linux:
$ g++ --version
g++ (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Thanks for your time.
-mandeep
next reply other threads:[~2020-07-09 20:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-09 20:31 Mandeep Sandhu [this message]
2020-07-09 20:49 ` Marc Glisse
2020-07-09 21:27 ` Mandeep Sandhu
2020-07-09 23:49 ` Jonathan Wakely
[not found] ` <CAC+QLdRqjTe4YsUpQRcLG7tpxGda0oh6H788ORZa5MQR3NqRbw@mail.gmail.com>
[not found] ` <CAH6eHdTRiwA3t1K3okfVc+umPM8PJfbePaO7AHdLz+SYPOU9XQ@mail.gmail.com>
2020-07-10 19:36 ` Mandeep Sandhu
2020-07-10 20:25 ` Jonathan Wakely
2020-07-11 6:27 ` Mandeep Sandhu
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=CAC+QLdSAw2sxrbAd4tS52_BtL22mTfUTBAGD2eohxFw6vNM+SA@mail.gmail.com \
--to=mandeepsandhu.chd@gmail.com \
--cc=gcc-help@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).