From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by sourceware.org (Postfix) with ESMTPS id 259923865491 for ; Thu, 9 Jul 2020 20:31:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 259923865491 Received: by mail-pl1-x630.google.com with SMTP id k4so1274966pld.12 for ; Thu, 09 Jul 2020 13:31:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=HnTSYnzjDJncpeIjo2ZKNdMrQPgcJuGwgDA+V4a1Syg=; b=WmFSyzk5RTH+y9V/YMl13YsH3KjsApofAw8ZLbu0q8odJNxCjZfB1Vm0oK2CEcu6yS iqAaEf9wiqQhRGhCdDXoPYjWOGjN04wlgKTgO7Z62Z15BVHSoiubB2Y0wFoSeCI3+V15 hwPJMW6XS403vLlFE532Spq6+LvVJJLdUuT5lJlYBnOrulXPQ7bu8XWSeR6M+bnzmgjW xd3xB7yeBCOC7pbaqTTuxNOdWFgaO6Wz9I6s0b0+eFZhJia9rVcrxiEwZC4Ex/JKace9 GoTj5xwN3161DBXebmg527xm/0c1xRFPKVaBGf7ekRH2f/FItv/iQpwatceShrA/uStr cH+g== X-Gm-Message-State: AOAM531MjnVRwOoqGUVTTXoUK/kLCf6bOkaJgmzgfCitp3sMFOdwA+YU hg5Y2xe+AUSv8HIoWRNNrVIS0Dd74hqXRBFESLXX+5X0uIk= X-Google-Smtp-Source: ABdhPJxhqzOi5TUhQ0T9ykzDB22LNZsRln+UWTAuDDV4MJBGFrCJz6X/nqi2ioeT3i+2YfkVYIRt42WZeidjR1MqkWE= X-Received: by 2002:a17:90b:405:: with SMTP id v5mr2024886pjz.226.1594326712781; Thu, 09 Jul 2020 13:31:52 -0700 (PDT) MIME-Version: 1.0 From: Mandeep Sandhu Date: Thu, 9 Jul 2020 13:31:41 -0700 Message-ID: Subject: stdc++ issue: extremely long compile time with large number of string literals To: gcc-help@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jul 2020 20:31:55 -0000 Hi All, I have an strange (to me) issue, where trying to compile a header which has a single "std::unordered_set" initialized with around 50K short strings is taking forever. The set is declared as: const std::unordered_set 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