From: Carlos O'Donell <carlos@redhat.com>
To: Joseph Myers <joseph@codesourcery.com>
Cc: Wilco Dijkstra <Wilco.Dijkstra@arm.com>,
"libc-alpha@sourceware.org" <libc-alpha@sourceware.org>,
nd <nd@arm.com>, Florian Weimer <fweimer@redhat.com>
Subject: Re: [PATCH v2] Add malloc micro benchmark
Date: Fri, 5 Jan 2018 09:26:30 -0800 [thread overview]
Message-ID: <a55c0575-f89d-0a05-7269-e38653b2b16e@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1801051621180.14880@digraph.polyomino.org.uk>
On 01/05/2018 08:28 AM, Joseph Myers wrote:
> On Fri, 5 Jan 2018, Carlos O'Donell wrote:
>
>> I think that for blocks smaller than the fundamental language types
>> (which require malloc to have 16-byte alignment) we do not have to
>> return sufficiently aligned memory. For example if you allocate a 3-byte
>> block or a 13-byte block, you cannot possibly put a 16-byte long double
>> there, nor can you use that for a stack block, so it's a waste to
>> guarantee alignment.
>
> As per DR#075, the memory needs to be aligned for any type of object (with
> a fundamental alignment requirement, in C11 and later), not just those
> that will fit in the block. (This in turn allows for applications using
> low bits for tagged pointers.)
Thanks for the reference to DR#075, I had not considered the cast equality
issue.
> This does not of course rule out having another allocation API that
> supports smaller alignment requirements.
Agreed.
It would still be a win if we did not have co-located metadata (something
Florian whispered into my ear years ago now) for small constant sized blocks.
We would go from this:
N * 1-byte allocations => N * (32-byte header
+ 1-byte allocation
+ 15-bytes alignment)
[97% constant waste]
To this:
N * 1-byte allocations => N * (1-byte allocation
+ 15-bytes alignment)
+ (N/8)-bytes in-use-bit + 16-bytes header
[96% waste for 1-byte]
[94% waste for 100*1-byte]
... towards a 93.75% constant waste (limit of the alignment e.g. 15/16)
This is a gain of 5% RSS efficiency for a structural change.
For a 13-byte allocation:
N * 1-byte allocations => N * (32-byte header
+ 13-byte allocation
+ 3-bytes alignment)
[73% constant waste]
To this:
N * 1-byte allocations => N * (13-byte allocation
+ 3-bytes alignment)
+ (N/8)-bytes in-use-bit + 16-bytes header
[60% waste for 13-bytes]
[20% waste for 100*13-bytes]
[19% waste for 1000*13-bytes]
... towards a 18.75% constant waste (limit of the alignment e.g. 3/16)
Note: We never reach the constant limit because the in-use bit-array still grows quickly.
--
Cheers,
Carlos.
next prev parent reply other threads:[~2018-01-05 17:24 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-01 13:51 [PATCH] Add malloc micro benchmark Wilco Dijkstra
2017-12-01 16:13 ` Carlos O'Donell
2017-12-18 15:18 ` Wilco Dijkstra
2017-12-18 16:32 ` Carlos O'Donell
2018-01-02 18:20 ` [PATCH v2] " Wilco Dijkstra
2018-01-02 18:45 ` DJ Delorie
2018-01-03 12:12 ` Wilco Dijkstra
2018-01-03 15:07 ` Carlos O'Donell
2018-01-04 13:48 ` Wilco Dijkstra
2018-01-04 16:37 ` Adhemerval Zanella
2018-01-05 14:32 ` Carlos O'Donell
2018-01-05 15:50 ` Adhemerval Zanella
2018-01-05 16:17 ` Carlos O'Donell
2018-01-05 16:46 ` Adhemerval Zanella
2018-01-05 17:27 ` Carlos O'Donell
2018-01-05 14:33 ` Carlos O'Donell
2018-01-05 16:28 ` Joseph Myers
2018-01-05 17:26 ` Carlos O'Donell [this message]
2018-02-28 12:40 ` Florian Weimer
2018-02-28 14:11 ` Ondřej Bílka
2018-02-28 14:16 ` Florian Weimer
2018-02-28 16:16 ` Carlos O'Donell
2018-02-28 20:17 ` Ondřej Bílka
2018-02-28 16:46 ` Ondřej Bílka
2018-02-28 17:01 ` Wilco Dijkstra
2018-02-28 18:21 ` Carlos O'Donell
2018-02-28 19:56 ` Ondřej Bílka
2018-02-28 21:56 ` DJ Delorie
2018-03-01 11:24 ` Ondřej Bílka
2017-12-18 23:02 ` [PATCH] " DJ Delorie
2017-12-28 14:09 ` Wilco Dijkstra
2017-12-28 19:01 ` DJ Delorie
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
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a55c0575-f89d-0a05-7269-e38653b2b16e@redhat.com \
--to=carlos@redhat.com \
--cc=Wilco.Dijkstra@arm.com \
--cc=fweimer@redhat.com \
--cc=joseph@codesourcery.com \
--cc=libc-alpha@sourceware.org \
--cc=nd@arm.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.
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).