mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Denys Vlasenko <vda.linux@googlemail.com>
To: Rich Felker <dalias@libc.org>
Cc: musl <musl@lists.openwall.com>
Subject: Re: [PATCH] configure: add gcc flags for better link-time optimization
Date: Sat, 24 Oct 2015 00:00:56 +0200	[thread overview]
Message-ID: <CAK1hOcPk8G82=oy4KxkThZzVuXgbNWyvZugw=6ac49KnSTaxkQ@mail.gmail.com> (raw)
In-Reply-To: <20151023144843.GJ8645@brightrain.aerifal.cx>

On Fri, Oct 23, 2015 at 4:48 PM, Rich Felker <dalias@libc.org> wrote:
>> 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.
>
> FYI all the data/bss in libc except a few large objects _easily_ fits
> in a single page.

What's importand is how many pages are dirtied.
Here's a test with Aboriginal's x86_64 static busybox:

# sleep 9999 | sh -c 'echo $$; exec ./busybox dd bs=1'
16290

# pmap 16290
16290:   ./busybox dd bs 1
0000000000400000    320K r-x--
/home/srcdevel/aboriginal/a.0/build/root-filesystem-x86_64/usr/bin/busybox
^^^^ text + rodata
000000000064f000      4K rw---
/home/srcdevel/aboriginal/a.0/build/root-filesystem-x86_64/usr/bin/busybox
^^^^ data + start of bss
0000000000650000      8K rw---    [ anon ]
^^^^ the rest of bss

0000000001655000      4K rw---    [ anon ]
^^^^ brk

00007fff57196000    132K rw---    [ stack ]
00007fff571df000      8K r----    [ anon ]
00007fff571e1000      8K r-x--    [ anon ]
ffffffffff600000      4K r-x--    [ anon ]
 total              488K


Thus, for this binary, three RW pages mapped immediately for .data and .bss,
for any applet.
Are all these pages touched?

# cat /proc/16290/smaps
00400000-00450000 r-xp 00000000 08:02 1810890
  /home/srcdevel/aboriginal/a.0/build/root-filesystem-x86_64/usr/bin/busybox
Size:                320 kB
...
0064f000-00650000 rw-p 0004f000 08:02 1810890
  /home/srcdevel/aboriginal/a.0/build/root-filesystem-x86_64/usr/bin/busybox
Size:                  4 kB
Rss:                   4 kB
Pss:                   4 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:         0 kB
Private_Dirty:         4 kB
Referenced:            4 kB
...
00650000-00652000 rw-p 00000000 00:00 0
Size:                  8 kB
Rss:                   4 kB
Pss:                   4 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:         0 kB
Private_Dirty:         4 kB
Referenced:            4 kB
Anonymous:             4 kB

No. Only two pages are mapped, not three.

This is pretty impressive. However, this is a small busybox config:
only 31 applet.

I have a complete (~320 applets) 32-bit static busybox config built
against uclibc, and it has only 2 pages .data+.bss

Will test & see how close to that can musl get.

I'll continue sending patches which allow to carry over some
data size reductions from uclibc to musl.


  reply	other threads:[~2015-10-23 22:00 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
2015-10-23 14:48     ` Rich Felker
2015-10-23 22:00       ` Denys Vlasenko [this message]
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='CAK1hOcPk8G82=oy4KxkThZzVuXgbNWyvZugw=6ac49KnSTaxkQ@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).