bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Curious... on readline history patch -- round up memory allocs?


From: Chet Ramey
Subject: Re: Curious... on readline history patch -- round up memory allocs?
Date: Wed, 16 Nov 2016 12:58:48 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

On 11/15/16 7:33 PM, L. A. Walsh wrote:

> ---
> That's fine -- I was just reading the comment about how 4.4 changed
> history allocs to optimize memory reallocs and movement.  So if things
> were fine with malloc before, I'm not sure why they were optimized
> within bash in 4.4...?

In the general case, realloc has to (internally) allocate a new block,
copy the contents from the old block to the new one, and free the old
block.  Reducing the number of reallocs reduces the number of potential
memory copies, which improves both memory locality and speed.

This doesn't have anything to do with aligning requests for memory on
page boundaries, which as Eduardo correctly notes, is the responsibility
of the malloc library layer.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]