Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Christian Biesinger via Gdb-patches <gdb-patches@sourceware.org>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Shrink size of dwarf2_per_cu_data
Date: Thu, 22 Apr 2021 16:39:22 -0500	[thread overview]
Message-ID: <CAPTJ0XGKL1qUP_NNDzgcsy3yNpzPjr6f=18sMrDeaQNJEDkV=w@mail.gmail.com> (raw)
In-Reply-To: <871rb3gryw.fsf@tromey.com>

On Wed, Apr 21, 2021 at 6:04 PM Tom Tromey <tom@tromey.com> wrote:
>
> >>>>> "Gary" == Gary Benson <gbenson@redhat.com> writes:
>
> Gary> Tom Tromey wrote:
> >> I noticed some holes in struct dwarf2_per_cu_data.  This patch
> >> rearranges the type slightly, and shrinks the size of some fields.
> >> This reduces it from 136 bytes to 112 bytes (on x86-64).
>
> Gary> Nice.  Though I'd assumed the compiler would do this.
>
> C and C++ compilers can't generally do this, though other languages like
> Rust and Ada do allow it.
>
> >> I also reduced the size of the DWARF "version" fields in a couple of
> >> spots.  It seemed needless to use a short to hold a value that
> >> ranges from 2 to 5, and this also helped the goal of shrinking
> >> dwarf2_per_cu_data.
>
> Gary> There's other things in there if you were going that way, e.g.:
>
> Gary>   unsigned char addr_size;
> Gary>   unsigned char signed_addr_p;
> Gary>   sect_offset abbrev_sect_off;
>
> Gary>   /* Size of file offsets; either 4 or 8.  */
> Gary>   unsigned int offset_size;
>
> Gary>   /* Size of the length field; either 4 or 12.  */
> Gary>   unsigned int initial_length_size;
>
> Gary> I presume you'd need to lose 8 whole bytes to shrink the struct
> Gary> further, so marking these as <8bit values probably wouldn't help
> Gary> any, but maybe it's worth it?
>
> I looked at this, and it doesn't remove enough space to help.
> Might still be worth doing for clarity, I dunno.
>
> Gary> How many CUs does something big
> Gary> have?
>
> gdb has 1197 as of today, but IMO it is moderately-sized at best.
> I don't have anything really big that's convenient to check.

I tried to approximate the number of CUs that Chrome has (Linux debug build):

$ objdump -g chrome | grep 'Compilation Unit' | wc -l
9233

Plus the parts that are in shared libraries:

$ find -name \*.so | xargs -n 1 objdump -g | grep 'Compilation Unit' | wc -l
57942

I'm not sure if all the .so files get loaded at the same time, so it
may be a bit fewer in practice. Of course this does not include any
CUs that may come from debug symbols for system libraries. Is there a
gdb command that could tell me the exact number?

Christian

  reply	other threads:[~2021-04-22 21:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-03 22:13 Tom Tromey
2020-11-04 10:59 ` Gary Benson via Gdb-patches
2021-04-21 23:04   ` Tom Tromey
2021-04-22 21:39     ` Christian Biesinger via Gdb-patches [this message]
2021-04-23 12:55       ` Tom Tromey

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='CAPTJ0XGKL1qUP_NNDzgcsy3yNpzPjr6f=18sMrDeaQNJEDkV=w@mail.gmail.com' \
    --to=gdb-patches@sourceware.org \
    --cc=cbiesinger@google.com \
    --cc=tom@tromey.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