public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Siddhesh Poyarekar <siddhesh@sourceware.org>
To: Wilco Dijkstra <Wilco.Dijkstra@arm.com>,
	'GNU C Library' <libc-alpha@sourceware.org>
Subject: Re: [PATCH] realloc: Return unchanged if request is within usable size
Date: Tue, 6 Dec 2022 13:41:33 -0500	[thread overview]
Message-ID: <71b9d4d0-f8cc-b40a-ca15-6f933ffa8b08@sourceware.org> (raw)
In-Reply-To: <PAWPR08MB8982C52A37922BAD06930416831B9@PAWPR08MB8982.eurprd08.prod.outlook.com>

On 2022-12-06 07:45, Wilco Dijkstra wrote:
> Hi Siddhesh,
> 
>>> We do need to handle the case where the size is smaller than the usable size since
>>> we'd still want to free the unused portion if it is a significant fraction of the total size.
>>
>> I'll make this a function of trim_threshold so that the reuse happens
>> only if the difference between the request and usable size is less than
>> the trim_threshold.
> 
> That's better, but that really only helps the mmap case, and all other reallocs will
> never release memory due to the 128KB default value of trim_threshold.

What I'm trying to ensure here is that holes are always less than the 
trim threshold.

> That's something we should explicitly decide/document and remove any redundant
> code from realloc as a result.

OK, I see the MINSIZE split is no longer relevant.

>>> Note the mmap code always tries to remap before checking the new size is smaller
>>> than usable size - so will end up remapping even if you downsize by one page.
>>
>> I don't see that; I've put the musable check before the
>> chunk_is_mmapped() check.  What am I missing?
> 
> I'm talking about the committed version, basically if there is any change in number of
> pages it will do a system call. With your change there must be at least 128KB worth of
> pages to be freed. We should do something similar for growing mmaps - large blocks
> should never grow/shrink a single page at a time.

Hmm, let me think about this.  I reckon this is going to need more 
sophisticated heuristics.

Thanks,
Sid

  reply	other threads:[~2022-12-06 18:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-28  9:22 Wilco Dijkstra
2022-11-28 14:13 ` Siddhesh Poyarekar
2022-12-06 12:45   ` Wilco Dijkstra
2022-12-06 18:41     ` Siddhesh Poyarekar [this message]
2023-07-03 22:02     ` Aurelien Jarno
2023-07-04 11:17       ` Siddhesh Poyarekar
2023-07-04 16:08         ` Aurelien Jarno
  -- strict thread matches above, loose matches on Subject: below --
2022-11-25 20:09 Siddhesh Poyarekar
2022-11-25 20:40 ` Andreas Schwab
2022-11-28 14:23   ` Siddhesh Poyarekar
2022-11-28 14:29     ` Andreas Schwab

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=71b9d4d0-f8cc-b40a-ca15-6f933ffa8b08@sourceware.org \
    --to=siddhesh@sourceware.org \
    --cc=Wilco.Dijkstra@arm.com \
    --cc=libc-alpha@sourceware.org \
    /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).