This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Another linker performance issue


A quite important performance issue in the linker can be resumed by this
profiling report (from gprof):

flat profile (first lines):

Each sample counts as 0.02 seconds.
  %   cumulative   self              self     total
 time   seconds   seconds    calls   s/call   s/call  name
 41.08    153.20   153.20 1991171953     0.00     0.00
pe_undef_alias_cdecl_match
 39.59    300.84   147.64    12871     0.01     0.02  bfd_link_hash_traverse
 14.12    353.48    52.64                             internal_mcount
  1.22    358.02     4.54 35793332     0.00     0.00  pe_undef_cdecl_match
  0.69    360.58     2.56       68     0.04     0.07
pe_walk_relocs_of_symbol
  0.52    362.51     1.93 136875717     0.00     0.00  cache_bread

The first two routines are taking 5 minutes to run!

The code is:

static bfd_boolean
pe_undef_alias_cdecl_match (struct bfd_link_hash_entry *h, void *inf)
{
  int sl;
  char *string = inf;
  const char *hs = h->root.string;

  sl = strlen (string);
  if (h->type == bfd_link_hash_undefined
      && ((*hs == '@' && (!pe_details->underscored || *string == '_')
	   && strncmp (hs + 1, string + (pe_details->underscored != 0),
		       sl - (pe_details->underscored != 0)) == 0)
	  || strncmp (hs, string, sl) == 0)
      && h->root.string[sl] == '@')
    {
      found_sym = h;
      return FALSE;
    }
  return TRUE;
}

static struct bfd_link_hash_entry *
pe_find_cdecl_alias_match (char *name)
{
  found_sym = 0;
  bfd_link_hash_traverse (link_info.hash, pe_undef_alias_cdecl_match,
			  (char *) name);
  return sym;
}

In fact we traverse the hash table, looking for all symbols for a
matching alias! For big applications this is not a proper
implementation. I've been contemplating this code since some time now
and cannot find a proper solution though (it looks like this will need
someone with good binutils internal understanding), so I'm looking for
advices.

Thoughts?

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]