From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by sourceware.org (Postfix) with ESMTPS id 41E523865491 for ; Thu, 9 Jul 2020 23:49:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 41E523865491 Received: by mail-io1-xd2e.google.com with SMTP id k23so4168282iom.10 for ; Thu, 09 Jul 2020 16:49:42 -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:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6FEscCLE2WCaj9nMys9q5SdIDE2YEQup3uh2mYkFRZw=; b=AdGvh4Ue8gHZap9e7Z1QOANRzbx/GQkDcuZZQKnez+4SIiu1dcbWCRTLHp6muAaUD4 TeJafPGboAYvfTQCY857WFm0BcsneFDJOcJOR43y+wPNHr16vyhVwxPcVqFzlHG95Whs cSlbN6WZa3WvEBqgTRW09/G2luA3ii7a0xN8K5LD4PlwESldTm4z8DBvMvqhyp+GAiP5 PouEURykXLFqzm7h0LMBttM9GZ5F+72LnCnGiov4mTW4VnY6/p+Z+HaVDHACyOyc4Pjs +2zDVzXtWdf4PFFwFO+YjwSj+q/Z7KmHIQqL4EEgI2CAEnv3ZupaBR2WRTmzmE2QSWAc IyIA== X-Gm-Message-State: AOAM531bsN5O9vg5qh7brN6ZqjQUaXzDpZuK2tZWGDeZwMK3d1HDcv9J 5IZkWzEaLl5yHZsSF8crlyGehx14uL8HR53Z/08= X-Google-Smtp-Source: ABdhPJzWL2Bouv5ooKLEZ+q83/cSGyWcQDMXNZwhj4tGeWXziB4qYkTrROq4Bat8j/T62LxH7PXobyTYuYUSEDeKcY8= X-Received: by 2002:a05:6602:2103:: with SMTP id x3mr44853628iox.130.1594338580971; Thu, 09 Jul 2020 16:49:40 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Fri, 10 Jul 2020 00:49:30 +0100 Message-ID: Subject: Re: stdc++ issue: extremely long compile time with large number of string literals To: Mandeep Sandhu Cc: gcc-help Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3.2 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 23:49:43 -0000 On Thu, 9 Jul 2020 at 21:34, Mandeep Sandhu via Gcc-help wrote: > > 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", ....}); This constructs an enormous array of std::string. If construction of any element of the array throws, then all previous elements need to be destroyed. There are known performance problems with the way G++ handles cases like this, because the exception handling creates a huge amount of overhead. You can find several bugs in bugzilla related to the construction of large arrays of non-trivial types.