From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7173 invoked by alias); 10 Mar 2005 21:31:47 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 7121 invoked from network); 10 Mar 2005 21:31:40 -0000 Received: from unknown (HELO sibelius.xs4all.nl) (82.92.89.47) by sourceware.org with SMTP; 10 Mar 2005 21:31:40 -0000 Received: from elgar.sibelius.xs4all.nl (elgar.sibelius.xs4all.nl [192.168.0.2]) by sibelius.xs4all.nl (8.13.0/8.13.0) with ESMTP id j2ALVUvF007473; Thu, 10 Mar 2005 22:31:30 +0100 (CET) Received: from elgar.sibelius.xs4all.nl (localhost [127.0.0.1]) by elgar.sibelius.xs4all.nl (8.12.6p3/8.12.6) with ESMTP id j2ALVU7H031676; Thu, 10 Mar 2005 22:31:30 +0100 (CET) (envelope-from kettenis@elgar.sibelius.xs4all.nl) Received: (from kettenis@localhost) by elgar.sibelius.xs4all.nl (8.12.6p3/8.12.6/Submit) id j2ALVPKX031671; Thu, 10 Mar 2005 22:31:25 +0100 (CET) Date: Thu, 10 Mar 2005 21:31:00 -0000 Message-Id: <200503102131.j2ALVPKX031671@elgar.sibelius.xs4all.nl> From: Mark Kettenis To: bje@au1.ibm.com CC: binutils@sources.redhat.com In-reply-to: <422CE744.7070409@au.ibm.com> (message from Ben Elliston on Tue, 08 Mar 2005 10:44:04 +1100) Subject: Re: PATCH: speed up ar(1) References: <422CE744.7070409@au.ibm.com> X-SW-Source: 2005-03/txt/msg00314.txt.bz2 Date: Tue, 08 Mar 2005 10:44:04 +1100 From: Ben Elliston 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 * 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);