public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* stdc++ issue: extremely long compile time with large number of string literals
@ 2020-07-09 20:31 Mandeep Sandhu
  2020-07-09 20:49 ` Marc Glisse
  2020-07-09 23:49 ` Jonathan Wakely
  0 siblings, 2 replies; 7+ messages in thread
From: Mandeep Sandhu @ 2020-07-09 20:31 UTC (permalink / raw)
  To: gcc-help

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-07-11  6:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-09 20:31 stdc++ issue: extremely long compile time with large number of string literals Mandeep Sandhu
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

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).