public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* RE: Re[2]: GAS
@ 2005-04-05  7:52 Zagorodnev, Grigory
  2005-04-06 11:17 ` GAS Nick Clifton
  0 siblings, 1 reply; 4+ messages in thread
From: Zagorodnev, Grigory @ 2005-04-05  7:52 UTC (permalink / raw)
  To: Stas Kiselev, binutils

>The idea is: huge input file implies huge symbol tables, that results
>more hash function collisions. Thus increasing the DEFAULT_SIZE of hash
>we can reduce the number of collisions and therefore speedup execution.
>Stas, would you try this on your sources, please?

Similar issue was reported against 'ld' 1.5 years ago. Simple change of
default hash size from 4K to 64K gave 2x link time improvement.
http://lists.gnu.org/archive/html/bug-gnu-utils/2003-08/msg00153.html

Thus the patch may look like this:

$ diff gas/hash.c.org gas/hash.c

38c38
< #define DEFAULT_SIZE (4051)
---
> #define DEFAULT_SIZE (65537)


- Grigory

^ permalink raw reply	[flat|nested] 4+ messages in thread
* Re: GAS
@ 2005-04-14  9:00 Nick Clifton
  2005-04-14  9:11 ` Re[2]: GAS Stas Kiselev
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Clifton @ 2005-04-14  9:00 UTC (permalink / raw)
  To: Zagorodnev, Grigory; +Cc: Stas Kiselev, binutils

[-- Attachment #1: Type: text/plain, Size: 886 bytes --]

Hi Griogry,

> Also there is a little problem with the patch: new command line option
> has no affect on symbol table and local symbol table hashes because
> routine parse_args gets called after symbol_begin in "as.c", where these
> hashes allocated. 

Ah - good point.  There was also a small problem with non-BFD assemblers 
in that the patch used the bfd_size_type.  Therefore I am applying the 
attached patch to fix both of these problems.

I checked - moving the parse_args before the symbol_begin does not 
appear to have any adverse effects.

Cheers
   Nick

gas/ChangeLog
2005-04-14  Nick Clifton  <nickc@redhat.com>

	* as.c (main): Move parse_args before symbol_begin and frag_init
	so that the hash table size can be set before it is used.
	* hash.c: Use an unsigned long type for the size of the hash
	tables.
	* hash.h (set_gas_hash_table_size): Update the prototype.	




[-- Attachment #2: gas.patch --]
[-- Type: text/plain, Size: 3872 bytes --]

Index: gas/as.c
===================================================================
RCS file: /cvs/src/src/gas/as.c,v
retrieving revision 1.59
diff -c -3 -p -r1.59 as.c
*** gas/as.c	12 Apr 2005 08:42:38 -0000	1.59
--- gas/as.c	14 Apr 2005 08:56:36 -0000
*************** the GNU General Public License.  This pr
*** 885,891 ****
  
  	case OPTION_HASH_TABLE_SIZE:
  	  {
! 	    bfd_size_type new_size;
  
              new_size = strtoul (optarg, NULL, 0);
              if (new_size)
--- 885,891 ----
  
  	case OPTION_HASH_TABLE_SIZE:
  	  {
! 	    unsigned long new_size;
  
              new_size = strtoul (optarg, NULL, 0);
              if (new_size)
*************** main (int argc, char ** argv)
*** 1114,1123 ****
  #endif
  
    PROGRESS (1);
    symbol_begin ();
    frag_init ();
    subsegs_begin ();
-   parse_args (&argc, &argv);
    read_begin ();
    input_scrub_begin ();
    expr_begin ();
--- 1114,1125 ----
  #endif
  
    PROGRESS (1);
+   /* Call parse_args before any of the init/begin functions
+      so that switches like --hash-size can be honored.  */
+   parse_args (&argc, &argv);
    symbol_begin ();
    frag_init ();
    subsegs_begin ();
    read_begin ();
    input_scrub_begin ();
    expr_begin ();
Index: gas/hash.c
===================================================================
RCS file: /cvs/src/src/gas/hash.c,v
retrieving revision 1.14
diff -c -3 -p -r1.14 hash.c
*** gas/hash.c	12 Apr 2005 08:42:38 -0000	1.14
--- gas/hash.c	14 Apr 2005 08:56:36 -0000
*************** struct hash_control {
*** 73,92 ****
     switch --reduce-memory-overheads, or set to other values by using
     the --hash-size=<NUMBER> switch.  */
  
! static unsigned int gas_hash_table_size = 65537;
  
  void
! set_gas_hash_table_size (unsigned int size)
  {
    gas_hash_table_size = size;
  }
  
  /* FIXME: This function should be amalgmated with bfd/hash.c:bfd_hash_set_default_size().  */
! static unsigned int
  get_gas_hash_table_size (void)
  {
    /* Extend this prime list if you want more granularity of hash table size.  */
!   static const unsigned int hash_size_primes[] =
      {
        1021, 4051, 8599, 16699, 65537
      };
--- 73,92 ----
     switch --reduce-memory-overheads, or set to other values by using
     the --hash-size=<NUMBER> switch.  */
  
! static unsigned long gas_hash_table_size = 65537;
  
  void
! set_gas_hash_table_size (unsigned long size)
  {
    gas_hash_table_size = size;
  }
  
  /* FIXME: This function should be amalgmated with bfd/hash.c:bfd_hash_set_default_size().  */
! static unsigned long
  get_gas_hash_table_size (void)
  {
    /* Extend this prime list if you want more granularity of hash table size.  */
!   static const unsigned long hash_size_primes[] =
      {
        1021, 4051, 8599, 16699, 65537
      };
*************** get_gas_hash_table_size (void)
*** 107,115 ****
  struct hash_control *
  hash_new (void)
  {
!   unsigned int size;
    struct hash_control *ret;
-   unsigned int alloc;
  
    size = get_gas_hash_table_size ();
  
--- 107,115 ----
  struct hash_control *
  hash_new (void)
  {
!   unsigned long size;
!   unsigned long alloc;
    struct hash_control *ret;
  
    size = get_gas_hash_table_size ();
  
Index: gas/hash.h
===================================================================
RCS file: /cvs/src/src/gas/hash.h,v
retrieving revision 1.7
diff -c -3 -p -r1.7 hash.h
*** gas/hash.h	12 Apr 2005 08:42:38 -0000	1.7
--- gas/hash.h	14 Apr 2005 08:56:36 -0000
*************** struct hash_control;
*** 26,32 ****
  
  /* Set the size of the hash table used.  */
  
! void set_gas_hash_table_size (unsigned int);
  
  /* Create a hash table.  This return a control block.  */
  
--- 26,32 ----
  
  /* Set the size of the hash table used.  */
  
! void set_gas_hash_table_size (unsigned long);
  
  /* Create a hash table.  This return a control block.  */
  

^ permalink raw reply	[flat|nested] 4+ messages in thread
* RE: Re[2]: GAS
@ 2005-04-05  5:45 Zagorodnev, Grigory
  0 siblings, 0 replies; 4+ messages in thread
From: Zagorodnev, Grigory @ 2005-04-05  5:45 UTC (permalink / raw)
  To: Stas Kiselev, binutils

[tacking the post back to mailing list so more people may attend]

It looks like we can slightly improve performance of 'hash_lookup'
function, which is platform-independent nevertheless. 

The idea is: huge input file implies huge symbol tables, that results
more hash function collisions. Thus increasing the DEFAULT_SIZE of hash
we can reduce the number of collisions and therefore speedup execution.
Stas, would you try this on your sources, please?

You can get more hash table runtime statistics (like number of lookups
or comparisons) with '--statistics'. That requires HASH_STATISTICS
defined at gas build time.

- Grigory

>-----Original Message-----
>From: Stas Kiselev [mailto:stas_kiselev@bk.ru]
>Sent: Monday, April 04, 2005 8:39 PM
>To: Zagorodnev, Grigory
>Subject: Re[2]: GAS
>
>Yes, I have been profiling it, but I don't know architecture of gas.
>Where can I get it ? What kind of blocks GAS consists of ? How they are
>interconnected ?
>
>After profiling I found out the most time consuming functions. There
some
>of them listed bellow:
>hash_lookup                                      15.4%
>sparc_ip                                         13.5%
>read_a_source_file                               4.6%
>do_scrub_chars (process input files              6.8%
>srtncpy  (standard C function )                  7%
>strncmp (standard C function )	                 6%
>strcmp  (standard C function )                   3.5%
>
>Is it a good idea to rewrite srtncpy, strncmp an strcmp ?
>I am interested only in Sun, Windows and Linux. What kind of functions
can
>I delete in order ot speed up GAS?
>What do you reccomend me to start ?
>I interested only in time of generating obj file. I am not interested
in
>optimisation of obj file.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-04-14  9:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-05  7:52 Re[2]: GAS Zagorodnev, Grigory
2005-04-06 11:17 ` GAS Nick Clifton
  -- strict thread matches above, loose matches on Subject: below --
2005-04-14  9:00 GAS Nick Clifton
2005-04-14  9:11 ` Re[2]: GAS Stas Kiselev
2005-04-05  5:45 Zagorodnev, Grigory

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).