public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fw@deneb.enyo.de>
To: ritesh sonawane <rdssonawane2317@gmail.com>
Cc: libc-help@sourceware.org
Subject: Re: Impact of Increasing M_MMAP_THRESHOLD to 1GB in malloc().
Date: Thu, 27 Sep 2018 17:46:00 -0000	[thread overview]
Message-ID: <87sh1uj0l8.fsf@mid.deneb.enyo.de> (raw)
In-Reply-To: <CAB8f8h0Pm5xdxU6zSYf9zk10eTvrwWekMmnMuW_pO=Bh23EQAQ@mail.gmail.com>	(ritesh sonawane's message of "Thu, 27 Sep 2018 22:30:51 +0530")

* ritesh sonawane:

> Yes it is 64 Bit target.
>
> Fragmentation means when malloc() request is more than threshold
> value, memory is allocated using mmap().  Due to size alignment with
> page size, there is memory wastage per request.  e.g. Our system is
> having 48GB memory, then total Number of malloc() requests (each
> 64MB) will be 380 and total used memory is 23 GB out of 48GB.

I see.  I agree that's a problem, and changing the malloc threshold
could be a solution.

> The system (NEC SX-Aurora TSUBASA) on which we are currently working
> is having huge page size and each process can have 16 GB and 512 GB
> address space for 2 MB and 64 MB page size respectively.

I'm not familiar with that system and haven't seen the glibc port,
sorry.  I used to work next door to a NEC SX-6 as a student, but
that's it.

> Also there is no particular limit on maximum heap size and Each
> thread can easily consumes 2 GB of address space and thats why we
> want to increase the M_MMAP_THRESHOLD to 1 GB.

If you do that, you also have to increase the heap size to something
like 32 GiB (HEAP_MAX_SIZE in malloc/arena.c).  The default of 2 *
DEFAULT_MMAP_THRESHOLD_MAX is probably too small (assuming that
DEFAULT_MMAP_THRESHOLD_MAX will be 2 GiB).  Otherwise you will have
substantial fragmentation for allocation requests between 2 GiB and
HEAP_MAX_SIZE.

I expect each heap will only allocate two pages via page faults, but
will reserve HEAP_MAX_SIZE bytes of address space.

If that's a problem, you could also make these changes, but set the
maximum arena count to 1, then only the main arena will be used, which
is sbrk-based.  The main arena doesn't need the coarse-grained
mappings with large power-of-two sizes.

  reply	other threads:[~2018-09-27 17:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-26  9:46 ritesh sonawane
2018-09-26 10:05 ` Florian Weimer
2018-09-27 16:55   ` ritesh sonawane
2018-09-27 17:46     ` Florian Weimer [this message]
2018-09-27 18:16       ` Carlos O'Donell
2018-09-28 10:22         ` ritesh sonawane
2018-09-28 10:40           ` Florian Weimer
2018-09-28 11:07             ` ritesh sonawane
2018-09-28 10:03       ` ritesh sonawane

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=87sh1uj0l8.fsf@mid.deneb.enyo.de \
    --to=fw@deneb.enyo.de \
    --cc=libc-help@sourceware.org \
    --cc=rdssonawane2317@gmail.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).