public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rich at testardi dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sources.redhat.com
Subject: [Bug libc/11261] malloc uses excessive memory for multi-threaded applications
Date: Sat, 27 Aug 2011 22:02:00 -0000	[thread overview]
Message-ID: <bug-11261-131-E5Y7K4W2Y2@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-11261-131@http.sourceware.org/bugzilla/>

http://sourceware.org/bugzilla/show_bug.cgi?id=11261

--- Comment #9 from Rich Testardi <rich at testardi dot com> 2011-08-27 22:02:03 UTC ---
Hi,

We ended up building our own memory allocator -- it's faster and more efficient
than glibc, and it works equally fast with threads and wihout.

We used the "small block allocator" concept from HP-UX where we only allocate
huge (32MB) allocations from the system (after setting M_MMAP_THRESHOLD
suitably small).

We then carve out large *naturally aligned* 1MB blocks from the huge allocation
(accepting 3% waste, since the allocation was page alogned to begin with, not
naturally aligned).

And we carve each one of those large blocks into small fixed size buckets
(which are fractional powers of 2 -- like 16 bytes, 20, 24, 28, 32, 40, 48, 56,
64, 80, etc.).

Then we put the aligned addresses into a very fast hash and have a linked list
for each bucket size.

This means our allocate routine is just a lock, linked list remove, unlock, on
average, and our free routine is just a hash lookup, lock, linked list insert,
unlock on average.

The trick here is that from any address being freed, you can get back to the
naturally aligned 1MB block that contains it with just a pointer mask, and from
there you can get the allocation's size as well as the head of the linked list
of free entries to which it should be returned...

-- Rich

  ----- Original Message ----- 
  From: heuler at infosim dot net 
  To: rich@testardi.com 
  Sent: Saturday, August 27, 2011 3:45 PM
  Subject: [Bug libc/11261] malloc uses excessive memory for multi-threaded
applications


  http://sourceware.org/bugzilla/show_bug.cgi?id=11261

  Marius Heuler <heuler at infosim dot net> changed:

             What    |Removed                     |Added
  ----------------------------------------------------------------------------
               Status|RESOLVED                    |REOPENED
                   CC|                            |heuler at infosim dot net
           Resolution|WONTFIX                     |

  --- Comment #8 from Marius Heuler <heuler at infosim dot net> 2011-08-27
21:45:04 UTC ---
  We have exactly the same problem with the current implementation of malloc.

  The suggested solutions by Ulrich using M_ARENA_MAX does not work since the
  check for number of arenas is not thread safe. In fact the limit is not
working
  for heay threading applications where that would be needed! 

  Since the number of cores and usage of threads will increase strongly there
  should be a solution for that kind of applications! If the arena limit would
  work as described we would have no problem.

  -- 
  Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
  ------- You are receiving this mail because: -------
  You reported the bug.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


  parent reply	other threads:[~2011-08-27 22:02 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-11261-131@http.sourceware.org/bugzilla/>
2011-08-27 21:45 ` heuler at infosim dot net
2011-08-27 22:02 ` rich at testardi dot com [this message]
2011-09-02  7:39 ` heuler at infosim dot net
2011-09-02  7:45 ` heuler at infosim dot net
2011-09-11 15:46 ` drepper.fsp at gmail dot com
2011-09-11 21:32 ` rich at testardi dot com
2012-07-29 10:10 ` zhannk at gmail dot com
2012-12-19 10:47 ` schwab@linux-m68k.org
2013-03-14 19:03 ` carlos at redhat dot com
2013-12-12  0:22 ` neleai at seznam dot cz
2013-12-12  3:32 ` siddhesh at redhat dot com
2013-12-12  8:41 ` neleai at seznam dot cz
2013-12-12 10:48 ` siddhesh at redhat dot com
2014-02-07  3:01 ` [Bug malloc/11261] " jsm28 at gcc dot gnu.org
2014-02-16 19:42 ` jackie.rosen at hushmail dot com
2014-05-28 19:46 ` schwab at sourceware dot org
2014-05-28 19:46 ` schwab at sourceware dot org
2014-06-30 18:50 ` fweimer at redhat dot com
2015-02-12 20:04 ` carlos at redhat dot com
2010-02-08 20:23 [Bug libc/11261] New: " rich at testardi dot com
2010-02-09 15:28 ` [Bug libc/11261] " drepper at redhat dot com
2010-02-09 16:02 ` rich at testardi dot com
2010-02-10 13:10 ` rich at testardi dot com
2010-02-10 13:21 ` drepper at redhat dot com
2010-02-10 13:42 ` rich at testardi dot com
2010-02-10 14:29 ` rich at testardi dot com
2010-02-10 15:52 ` rich at testardi dot com

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-11261-131-E5Y7K4W2Y2@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sources.redhat.com \
    /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).