From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5713 invoked by alias); 5 Nov 2012 22:12:28 -0000 Received: (qmail 5677 invoked by uid 48); 5 Nov 2012 22:12:14 -0000 From: "tlawrence85 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/54075] [4.7.1] unordered_map insert still slower than 4.6.2 Date: Mon, 05 Nov 2012 22:12:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tlawrence85 at gmail dot com X-Bugzilla-Status: REOPENED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: fdumont at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: CC Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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-11/txt/msg00437.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D54075 Lawrence changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tlawrence85 at gmail dot | |com --- Comment #36 from Lawrence 2012-11-05 22:= 12:12 UTC --- It seems that this commit doesn't fully fix this issue. If you call rehash multiple times with the same size, the second call to rehash resets _M_prev_resize to a non-zero value in _M_next_bkt(). Here is a sample progr= am that shows this behavior: #include #include int main(void) { std::unordered_map myMap; myMap.rehash(4000000); myMap.rehash(4000000); unsigned long long buckets =3D myMap.bucket_count(); int i =3D 0; while (i < 2000000000) { myMap.insert(std::make_pair(i, 0)); ++i; if (buckets !=3D myMap.bucket_count()) { printf("buckets %lu -> %lu\n", buckets, myMap.bucket_count()); buckets =3D myMap.bucket_count(); } } return 0; } (In reply to comment #13) > Author: fdumont > Date: Thu Jul 26 12:31:50 2012 > New Revision: 189889 >=20 > URL: http://gcc.gnu.org/viewcvs?root=3Dgcc&view=3Drev&rev=3D189889 > Log: > 2012-07-26 Fran=C3=A7ois Dumont >=20 > PR libstdc++/54075 > * include/bits/hashtable.h > (_Hashtable<>::_Hashtable(_InputIterator, _InputIterator, > size_type, ...): Remove std::max usage to guarantee that hashtable > state is consistent with hash policy state. > (_Hashtable<>::rehash): Likewise. Set _M_prev_resize to 0 to avoid > the hashtable shrinking on next insertion. > * testsuite/23_containers/unordered_set/modifiers/reserve.cc: New. > * testsuite/23_containers/unordered_multiset/modifiers/reserve.cc: Ne= w. > * testsuite/23_containers/unordered_map/modifiers/reserve.cc: New. > * testsuite/23_containers/unordered_multimap/modifiers/reserve.cc: Ne= w. >=20 > Added: >=20=20=20=20 > branches/gcc-4_7-branch/libstdc++-v3/testsuite/23_containers/unordered_ma= p/modifiers/reserve.cc >=20=20=20=20 > branches/gcc-4_7-branch/libstdc++-v3/testsuite/23_containers/unordered_mu= ltimap/modifiers/reserve.cc >=20=20=20=20 > branches/gcc-4_7-branch/libstdc++-v3/testsuite/23_containers/unordered_mu= ltiset/modifiers/reserve.cc >=20=20=20=20 > branches/gcc-4_7-branch/libstdc++-v3/testsuite/23_containers/unordered_se= t/modifiers/reserve.cc > Modified: > branches/gcc-4_7-branch/libstdc++-v3/ChangeLog > branches/gcc-4_7-branch/libstdc++-v3/include/bits/hashtable.h