mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: [musl] Options for mallocng+ldso reclaim_gaps
Date: Tue, 12 May 2020 18:08:02 -0400	[thread overview]
Message-ID: <20200512220801.GS21576@brightrain.aerifal.cx> (raw)

I have an out-of-tree mockup of the ldso reclaim_gaps equivalent for
mallocng. Right now the way it works is by repeatedly placing a
single-slot group of each power-of-two-sized class (in which nested
groups can be allocated) that fits, in order of decreasing powers. So
a 2600 byte gap would get filled with

- 2048 (16 header + 1x2032)
- 512 (16 header + 1x496)
- (remainder 40 bytes too small to be useful)

This yields a total of 5x496 for groups of small allocations, and even
some larger things like 2x240 that might be useful for struct dso. But
it's only one option.

The other option is treating each donation as a blank slate for bump
allocation of permanent groups of any size that fit. For example the
above could fit:

- 1x1632, 1x676, 1x240
- 1x1344, 1x672, 1x496[, 1x64]
- 1x1008, 1x1344, 1x240
- etc.

Desptie this seeming attractive, the permanence of the division (it
really doesn't make sense to make any complex dlmalloc reinvention for
merging these back for reuse in different divisions) means it's very
possible that small programs that benefit the most from reclaim_gaps
might never get to use the reclaimed memory again, if they don't need
the same size class again. On the other hand, the largest-fit
power-of-two mockup I have now gives slots that can hold almost any
nested group of smaller size.

Thoughts on any of this? Anything I might be missing in pros or cons
or other reasonable choices that might be better?

             reply	other threads:[~2020-05-12 22:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-12 22:08 Rich Felker [this message]
2020-06-07  2:13 ` Rich Felker

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=20200512220801.GS21576@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).