mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Denys Vlasenko <vda.linux@googlemail.com>
To: musl <musl@lists.openwall.com>, Rich Felker <dalias@libc.org>,
	 Denys Vlasenko <vda.linux@googlemail.com>
Subject: Re: [PATCH] configure: add gcc flags for better link-time optimization
Date: Fri, 23 Oct 2015 16:41:17 +0200	[thread overview]
Message-ID: <CAK1hOcOLNXGckxO9y7M7shwM+NvTOvna=nwNGBJmdBwD2FrM1Q@mail.gmail.com> (raw)
In-Reply-To: <20151023131202.GI10551@port70.net>

On Fri, Oct 23, 2015 at 3:12 PM, Szabolcs Nagy <nsz@port70.net> wrote:
>> +# When linker merges sections, a tiny section (such as one resulting
>> +# from "static char flag_var") with no alignment restrictions
>> +# can end up logded between two more strongly aligned ones (say,
>> +# "static int global_cnt1/2", both of which want 32-bit alignment).
>> +# Then this byte-sized "flag_var" gets 3 bytes of padding.
>> +#
>> +# With section sorting by alignment, one-byte flag variables have
>> +# higher chance of being grouped together and not require padding.
>> +# (It can be made even better. Linker is too dumb.
>> +# ld needs to grow -Wl,--pack-sections-optimally)
>> +#
>> +# For us, this affects the size of only one file: libc.so
>> +#
>> +tryldflag LDFLAGS_AUTO -Wl,--sort-section=alignment
>> +tryldflag LDFLAGS_AUTO -Wl,--sort-common
>
> i think this came up before
> https://sourceware.org/bugzilla/show_bug.cgi?id=14156
>
> it was also noted at some point that the optimal sorting
> is 'sort by use' so all the unused legacy functions end
> up on the same page so they never need to be loaded.

Sure, but that would be quite hard to do.
How would you reliably know who uses which part of libc
code?

OTOH, we don't _need_ to kill ourselves trying to optimize
that. Optimizing code size is not the big thing here.
Even though data and bss shrinkage is smaller,
it is more important.

Minimizing the number of data pages is more important
than text pages. A text page is shared among all processes linked
to this libc.so; data page is allocated in every process
(as soon as even one byte in this page is written to.
With only 4 pages in total like in this example, I'm pretty sure
all of them get dirtied by libc init, use of stdio or malloc).

Make libc (.data + .bss) fit into one page less and you get about
as many pages saved as you have processes running.


  reply	other threads:[~2015-10-23 14:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-23 12:30 Denys Vlasenko
2015-10-23 13:12 ` Szabolcs Nagy
2015-10-23 14:41   ` Denys Vlasenko [this message]
2015-10-23 14:48     ` Rich Felker
2015-10-23 22:00       ` Denys Vlasenko
2015-10-24 12:43         ` Szabolcs Nagy
2015-10-24 19:20           ` Rich Felker
2015-10-27  1:21   ` Rich Felker
2015-10-27 19:09     ` Denys Vlasenko
2015-10-27 21:01       ` Rich Felker
2015-10-28  9:53         ` Denys Vlasenko
2015-10-28 10:05           ` Denys Vlasenko
2015-11-01 19:56 ` Rich Felker
2015-11-02 22:36   ` Rich Felker
2015-11-03  0:01     ` Rich Felker
2015-11-05  2:58       ` 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='CAK1hOcOLNXGckxO9y7M7shwM+NvTOvna=nwNGBJmdBwD2FrM1Q@mail.gmail.com' \
    --to=vda.linux@googlemail.com \
    --cc=dalias@libc.org \
    --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).