From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9973 invoked by alias); 30 Nov 2014 19:40:39 -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 9931 invoked by uid 48); 30 Nov 2014 19:40:34 -0000 From: "gcc-bugzilla at contacts dot eelis.net" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/64128] New: Let vector take advantage of malloc_usable_size for malloc-using allocators Date: Sun, 30 Nov 2014 19:40: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-Version: 4.8.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gcc-bugzilla at contacts dot eelis.net X-Bugzilla-Status: UNCONFIRMED 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_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: 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: 2014-11/txt/msg03452.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64128 Bug ID: 64128 Summary: Let vector take advantage of malloc_usable_size for malloc-using allocators Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: gcc-bugzilla at contacts dot eelis.net Created attachment 34150 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34150&action=edit testcase Changing this->_M_impl._M_end_of_storage = __new_start + __len; to this->_M_impl._M_end_of_storage = __new_start + malloc_usable_size(__new_start) / sizeof(value_type); in vector.tcc makes the runtime of the attached program drop from 0.35 seconds to 0.24 seconds on my machine, a 31% reduction. This shows there is low hanging fruit for a very common operation (vector::push_back). A proper implementation would of course only do this for allocators that are known to be malloc frontends. :)