From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28285 invoked by alias); 23 Jul 2012 23:07:14 -0000 Received: (qmail 28276 invoked by uid 22791); 23 Jul 2012 23:07:13 -0000 X-SWARE-Spam-Status: No, hits=-3.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 Jul 2012 23:06:58 +0000 From: "likan_999.student at sina dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/54075] New: [4.7.1] unordered_map 3x slower than 4.6.2 Date: Mon, 23 Jul 2012 23:07:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Keywords: X-Bugzilla-Severity: critical X-Bugzilla-Who: likan_999.student at sina dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-07/txt/msg01810.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54075 Bug #: 54075 Summary: [4.7.1] unordered_map 3x slower than 4.6.2 Classification: Unclassified Product: gcc Version: 4.7.1 Status: UNCONFIRMED Severity: critical Priority: P3 Component: libstdc++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: likan_999.student@sina.com The following piece of code shows 3x performance regression from 4.6.2 to 4.7.1. The reason should come from the change in libstdc++. The code is compiled with -O2 -std=c++0x. -O3 doesn't make much difference; with or without the call to reserve doesn't make much difference. The attachment contains profiling using google-perftool. Looks like the major cost comes from the rehashing. Does anyone aware of the issue, or I am the first one to report this? #include using namespace std; int main() { const int N = 10000000; unordered_map m; m.reserve(2 * N); for (int i = 0; i < N; i++) { m[i] = i; } } Timing: [hidden]$ time ./a-4.6.2.out real 0m1.029s user 0m0.787s sys 0m0.239s [hidden]$ time ./a-4.7.1.out real 0m3.364s user 0m2.596s sys 0m0.761s