This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: PATCH: speed up ar(1)
- From: Mark Kettenis <kettenis at gnu dot org>
- To: bje at au1 dot ibm dot com
- Cc: binutils at sources dot redhat dot com
- Date: Thu, 10 Mar 2005 22:31:25 +0100 (CET)
- Subject: Re: PATCH: speed up ar(1)
- References: <422CE744.7070409@au.ibm.com>
Date: Tue, 08 Mar 2005 10:44:04 +1100
From: Ben Elliston <bje@au1.ibm.com>
The following patch alters the ar cache representation from a
singly linked list to a hash table using the hashtab implementation
from libiberty. When archiving files with thousands of archive
members (eg. libjava), this patch results in a 15-25% performance
improvement.
Tested with an --enable-targets=all build, make check-binutils and
a byte-wise comparison of the libjava libraries built with and
without a patched ar.
But with a compiler that's far too modern for your own good ;-).
Okay to commit?
Not really; this isn't proper ISO C90...
Index: archive.c
===================================================================
RCS file: /home/bje/src-cvs/src/bfd/archive.c,v
retrieving revision 1.34
diff -u -r1.34 archive.c
--- archive.c 3 Mar 2005 11:40:56 -0000 1.34
+++ archive.c 7 Mar 2005 22:48:34 -0000
@@ -247,14 +247,36 @@
bfd *
_bfd_look_for_bfd_in_cache (bfd *arch_bfd, file_ptr filepos)
{
- struct ar_cache *current;
+ struct ar_cache m;
+ m.ptr = filepos;
- for (current = bfd_ardata (arch_bfd)->cache; current != NULL;
- current = current->next)
- if (current->ptr == filepos)
- return current->arelt;
+ htab_t hash_table = bfd_ardata (arch_bfd)->cache;
But since it already went in, I committed the attached obvious patch.
Take care,
Mark
Index: ChangeLog
from Mark Kettenis <kettenis@gnu.org>
* archive.c (_bfd_look_for_bfd_in_cache): Move declaration of
has_table to the start of the function.
Index: archive.c
===================================================================
RCS file: /cvs/src/src/bfd/archive.c,v
retrieving revision 1.35
diff -u -p -r1.35 archive.c
--- archive.c 10 Mar 2005 00:29:35 -0000 1.35
+++ archive.c 10 Mar 2005 21:25:21 -0000
@@ -247,10 +247,10 @@ bfd_set_archive_head (bfd *output_archiv
bfd *
_bfd_look_for_bfd_in_cache (bfd *arch_bfd, file_ptr filepos)
{
+ htab_t hash_table = bfd_ardata (arch_bfd)->cache;
struct ar_cache m;
m.ptr = filepos;
- htab_t hash_table = bfd_ardata (arch_bfd)->cache;
if (hash_table)
{
struct ar_cache *entry = (struct ar_cache *) htab_find (hash_table, &m);