Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 21 Sep 2022 14:42:40 +0600
From: NRK <>
Subject: Re: The heap memory performance (malloc/free/realloc) is
 significantly degraded in musl 1.2 (compared to 1.1)

On Wed, Sep 21, 2022 at 04:45:59AM +0800, baiyang wrote:
> Yes, we will adapt as many allocators as possible to make our software
> more portable and adaptable.
> Of course, we also respect and understand the author's considerations
> and trade-offs, and have avoided calling malloc_usable_size for musl's
> mallocng in our software.

Here's a better idea, malloc (and malloc_usable_size) cannot be slow if
you never call it; so just skip it all together and grab the needed
pages straight from the kernel (mmap(2) on linux/posix and on windows I
think it's VirtualAlloc).

The malloc API was designed for ease of use, not performance. And it's
evident from the fact that user has no control over malloc's metadata.

And what you're doing with malloc_usable_size() is not an
"optimization", it's a heuristic at best and hack that'll actually
*pessimize* at worse. Proof? This very thread.

Also malloc_usable_size() does not tell you anything about weather
realloc will grow in place (or avoid copy entirely via virtual address
space shenanigans).

If you need such fine grained control then you're using the wrong API,
you either need to manage your memory directly or find an allocator
library which *actually* (as in documented in the API contract) offers
such control rather than relying on unreliable heuristics.


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.