changing the default hash table size (was improving ld performance)

Nick Clifton nickc@redhat.com
Fri May 21 15:47:00 GMT 2004


Hi Andy,

  I am very sorry for forgetting about this patch. :-(

  I have now had a chance to review it and I am going to apply it,
  albeit in a slightly different version.  I made the following
  changes:

    * I create ChangeLog entries for the bfd/ and ld/ directories.

    * I added documentation of the new switch to ld/ld.texinfo and
      ld/NEWS.

    * I added support for setting the default hash table size to the
      new --reduce-memory-overheads linker switch.  I also added an
      entry for 1021 to the hash_size_primes[] array which is used by
      this switch.

    * I removed the debugging fprintf() from
      bfd_hash_set_default_size().

    * I fixed up the formatting to conform to the GNU Coding
      Standard.

    * I simplified the code in bfd_hash_set_default_size in order to
      eliminate the new_hash_size and nhash_size_primes variables.  I
      also moved the hash_size_primes[] array into this function since
      it is only used here.

  Incidentally whilst checking this patch I noticed that if the
  default hash table size is set to 8599 quite a few linker tests
  fail.  I did not investigate this fully, but I suspect that this is
  because the tests have certain values inappropriately hardwired into
  their expected results.  You might like to investigate this
  yourself.

Cheers
        Nick

PS.  Here is the patch that I applied.

bfd/ChangeLog
2004-05-21  Nick Clifton  <nickc@redhat.com>

	* hash.c (bfd_default_hash_table_size): New variable.
	(bfd_hash_table_init): Use new variable instead of DEFAULT_SIZE.
	(bfd_hash_set_default_size): New function.  Set the default size
	to a selected prime number close to the argument.  Document new
	function.
	* bfd-in.h: Add prototype for  bfd_hash_set_default_size.
	* bfd-in2.h: Regenerate.
	* Makefile.am (hash.lo): Add dependency upon libiberty.h.
	* Makefile.in: Regenerate.

ld/ChangeLog
2004-05-21  Nick Clifton  <nickc@redhat.com>

	* ld.h (ld_config_type): Add new field: hash_table_size.
	* ldmain.c: Initialise the new field to zero.  If it is non-zero
	after parsing the linker's command line call
	bfd_hash_set_default_size.
	* lexsup.c (option_values): Add OPTION_HASH_SIZE.
	(ld_options): Add hash-size.
	(parse_args): Parse --hash-size option.  Allow
	--reduce-memory-overheads to set the default hash table size as
	well.
	* ld.texinfo: Document the new switch.  Also mention that
	--reduce-memory-overheads can affect the hash table size.
	* NEWS: Mention the new feature.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: hash-size.patch
Type: text/x-patch
Size: 16739 bytes
Desc: Add --hash-size=<NUMBER> switch to the linker
URL: <https://sourceware.org/pipermail/binutils/attachments/20040521/c12ee2fb/attachment.bin>


More information about the Binutils mailing list