public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H. J. Lu" <hjl@lucon.org>
To: Nick Clifton <nickc@redhat.com>, binutils@sources.redhat.com
Subject: Slow lang_output_section_find_1
Date: Fri, 18 Mar 2005 20:04:00 -0000	[thread overview]
Message-ID: <20050318193325.GA32010@lucon.org> (raw)
In-Reply-To: <20050318131431.GA21148@bubble.modra.org>

On Fri, Mar 18, 2005 at 11:44:31PM +1030, Alan Modra wrote:
> On Fri, Mar 18, 2005 at 10:01:03AM +0000, Nick Clifton wrote:
> > Hi H. J.
> > 
> > >When we have many orphaned sections, lang_insert_orphan spends lots
> > >of time in
> > >
> > >/* Unlink the section.  */
> > >for (pps = &output_bfd->sections; *pps != snew; pps = &(*pps)->next)
> > >  continue;
> > >
> > >It is the case of 64K section ld test. Use a doubly linked list
> > >for section may help. But it will add a pointer to bfd_section. Should
> > >I give a try?
> > 
> > I am reluctant to increase the size of the bfd_section structure.  Maybe 
> >  lang_insert_orphans() could be made smarter with a different algorithm 
> > ?  Possibly it could keep a local bitmap or list of sections to unlink 
> > and then only unlink them all right at the end ?
> 
> Yes, I think you could try other approaches first.  For instance
> I think it would be better to ask ourselves whether this list really
> needs to be ordered.  Before I wrote this code, orphan sections appeared
> at the end of the section list.  As the comment says, shuffling the
> section list was only cosmetic, but now I see some code has crept into
> lang_size_section, for DATA_SEGMENT_ALIGN, that depends on correct
> section ordering.  The lang_size_section code could easily be rewritten
> to traverse the lang_output_section_statement list instead.
> 
> If we do care about the ordering, then perhaps delay sorting the
> bfd_section list according to the output section statement list until
> after all orphans have been added.  Hmm, probably the best thing would
> be to save output_bfd->section_tail before adding the orphan.  Then you
> know how to unlink the orphan without looking through the list.  (I
> think the orphan code predated the section hash table and section_tail.)

With Alan's fix to lang_insert_orphan, lang_output_section_find_1
becomes the most time consuming part of ld:

 62.81   1156.48  1156.48        1     1.16     1.83  lang_process
 32.51   1755.16   598.68   128089     0.00     0.00 lang_output_section_find_1
  2.43   1799.93    44.77   640881     0.00     0.00  bfd_hash_lookup
  1.22   1822.38    22.45    13002     0.00     0.00  walk_wild_section
  0.16   1825.26     2.88   128221     0.00     0.00 get_special_section

I don't think the current linker is designed to support many many output
sections. Should we use a hash table or doubly linked list to avoid
the linear search over a linked list of more than 64K sections?


H.J.

  parent reply	other threads:[~2005-03-18 19:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-17 19:59 Slow lang_insert_orphan H. J. Lu
2005-03-18 10:45 ` Nick Clifton
2005-03-18 15:08   ` Alan Modra
2005-03-18 15:17     ` Alan Modra
2005-03-18 16:24     ` H. J. Lu
2005-03-18 20:04     ` H. J. Lu [this message]
2005-03-19  1:51       ` Slow lang_output_section_find_1 Alan Modra

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=20050318193325.GA32010@lucon.org \
    --to=hjl@lucon.org \
    --cc=binutils@sources.redhat.com \
    --cc=nickc@redhat.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).