From: Paul Mackerras <paulus@samba.org>
To: Emil Medve <Emilian.Medve@Freescale.com>
Cc: sfr@canb.auug.org.au, rusty@rustcorp.com.au,
linuxppc-dev@ozlabs.org, ntl@pobox.com,
linuxppc-embedded@ozlabs.org
Subject: Re: [PATCH] [POWERPC] Optimize counting distinct entries in the relocation sections
Date: Mon, 12 Nov 2007 17:00:43 +1100 [thread overview]
Message-ID: <18231.60427.229658.485287@cargo.ozlabs.ibm.com> (raw)
In-Reply-To: <1194564963-15626-1-git-send-email-Emilian.Medve@Freescale.com>
Emil Medve writes:
> (Not sure why the relocation tables could contain lots of duplicates and why
> they are not trimmed at compile time by the linker. In some test cases, out of
> 35K relocation entries only 1.5K were distinct/unique)
Presumably you have lots of calls to the same function, or lots of
references to the same variable.
Actually I notice that count_relocs is counting all relocs, not just
the R_PPC_REL24 ones, which are all that we actually care about in
sizing the PLT. And I would be willing to bet that every single
R_PPC_REL24 reloc has r_addend == 0.
Also I notice that even with your patch, the actual process of doing
the relocations will take time proportional to the product of the
number of PLT entries times the number of R_PPC_REL24 relocations,
since we do a linear search through the PLT entries each time.
So, two approaches suggest themselves. Both optimize the r_addend=0
case and fall back to something like the current code if r_addend is
not zero. The first is to use the st_other field in the symbol to
record whether we have seen a R_PPC_REL24 reloc referring to the
symbol with r_addend=0. That would make count_relocs of complexity
O(N) for N relocs.
The second is to allocate an array with 1 pointer per symbol that
points to the PLT entry (if any) for the symbol. The count_relocs
scan can then use that array to store a 'seen before' flag to make its
scan O(N), and do_plt_call can then later use the same array to find
PLT entries without needing the linear scan.
As far as your proposed patch is concerned, I don't like having a
function called "count_relocs" changing the array of relocations. At
the very least it needs a different name. But I also think we can do
better than O(N * log N), as I have explained above, if my assertion
that r_addend=0 in all the cases we care about is correct.
Paul.
next prev parent reply other threads:[~2007-11-12 6:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-08 23:36 [PATCH] [POWERPC] Optimize counting distinct entries in the relocation sections Emil Medve
2007-11-12 6:00 ` Paul Mackerras [this message]
2007-11-12 8:01 ` Rusty Russell
2007-11-12 11:55 ` Modulo operation in C for -ve values Deepak Gaur
2007-11-12 16:50 ` [PATCH] [POWERPC] Optimize counting distinct entries in the relocation sections Medve Emilian
2007-11-12 22:31 ` [PATCH] [POWERPC] Optimize counting distinct entries in therelocation sections Medve Emilian
2007-11-13 2:49 ` Paul Mackerras
2007-11-13 4:27 ` Rusty Russell
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=18231.60427.229658.485287@cargo.ozlabs.ibm.com \
--to=paulus@samba.org \
--cc=Emilian.Medve@Freescale.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=linuxppc-embedded@ozlabs.org \
--cc=ntl@pobox.com \
--cc=rusty@rustcorp.com.au \
--cc=sfr@canb.auug.org.au \
/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 NNTP newsgroup(s).