public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "gcc-bugzilla at contacts dot eelis.net" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-64128-4@http.gcc.gnu.org/bugzilla/> (raw)

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. :)


             reply	other threads:[~2014-11-30 19:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-30 19:40 gcc-bugzilla at contacts dot eelis.net [this message]
2014-12-01  0:01 ` [Bug libstdc++/64128] " gcc-bugzilla at contacts dot eelis.net
2014-12-01 11:14 ` redi at gcc dot gnu.org
2014-12-01 17:14 ` gcc-bugzilla at contacts dot eelis.net

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-64128-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).