From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 74700 invoked by alias); 2 Apr 2015 12:56:03 -0000 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 Received: (qmail 74651 invoked by uid 48); 2 Apr 2015 12:56:00 -0000 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/65641] unordered_map - __detail::_Mod_range_hashing is slow Date: Thu, 02 Apr 2015 12:56: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-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on cc everconfirmed bug_severity Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-04/txt/msg00147.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65641 Jonathan Wakely changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2015-04-02 CC| |fdumont at gcc dot gnu.org Ever confirmed|0 |1 Severity|normal |enhancement --- Comment #3 from Jonathan Wakely --- (In reply to Jens Breitbart from comment #2) > Another possible solution would be to allow the number of buckets to be a > power of two, as one can easily compute the mask for such cases. This could > be triggered by the user explicitly calling rehash() with a power of two as > the parameter. Increasing the number of buckets would only increase to > another power of two. _Mod_range_hashing could check if the number of > buckets is a power of two and use masking in that case. This would not > require an ABI change. That sounds promising, and worth pursuing. > Any chance of getting such a change upstream? I don't see why not, although unless you have a GCC copyright assignment on file, or plan to get one (immediately, since it can take a while) it's better *not* to give us a patch, because we can't use it anyway and there can be no danger of using your code if we don't see it! > As far as I can see, there > seems to be no easy way to have the unorered_map use our folding functor > instead of _Mod_range_hashing or am I missing something? I think you would need to use the _Hastable class template directly, rather than via std::unordered_map. In theory that allows you to re-use the internals with different policies, but in practice it's not very easy.