From: Micha Nelissen <nelissen.micha@gmail.com>
To: musl@lists.openwall.com
Subject: Re: [PATCH] Use open_memstream(3) for more efficient asprintf
Date: Mon, 14 Oct 2019 15:57:31 +0200 [thread overview]
Message-ID: <f9653a97-95a8-fb83-1f80-f8d2ae8f7a48@gmail.com> (raw)
In-Reply-To: <20191014120727.GJ16318@brightrain.aerifal.cx>
On 14-10-2019 14:07, Rich Felker wrote:
> - avoiding quadratic-time worst-case (from the memcpy in realloc with
> linear buffer size growth at each step) or internal fragmentation
> (from geometric buffer growth at each step). Our current memstream
> implementation uses linear growth I think so it would be the former
> (quadratic time)
This seems to imply linear buffer size growth doesn't cause
fragmentation? In general it does I would assume.
> - avoiding fragmentation produced by realloc
I guess the idea behind the original malloc(GUESS) (and also this
memstream implementation?) is that it allocates from end of heap, and
therefore realloc is very cheap: just move end of heap pointer. Although
in a multi-threaded world this becomes less likely depending on the
intensity of malloc/realloc usage by other threads.
Micha
next prev parent reply other threads:[~2019-10-14 13:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-14 6:48 Alex Brachet-Mialot
2019-10-14 6:56 ` Alex Brachet-Mialot
2019-10-14 12:12 ` Rich Felker
2019-10-14 12:07 ` Rich Felker
2019-10-14 13:57 ` Micha Nelissen [this message]
2019-10-14 14:23 ` 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=f9653a97-95a8-fb83-1f80-f8d2ae8f7a48@gmail.com \
--to=nelissen.micha@gmail.com \
--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).