From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 28662 invoked from network); 17 May 1998 12:06:24 -0000 Received: from leibniz.math.fu-berlin.de (HELO math.fu-berlin.de) (qmailr@160.45.40.10) by mail2.redhat.com with SMTP; 17 May 1998 12:06:24 -0000 Received: (qmail 2243 invoked from network); 17 May 1998 12:06:17 -0000 Received: from landau.math.fu-berlin.de (HELO math.fu-berlin.de) (qmailr@160.45.40.69) by leibniz.math.fu-berlin.de with SMTP; 17 May 1998 12:06:17 -0000 Received: (qmail 18220 invoked by uid 8044); 17 May 1998 12:06:14 -0000 Message-ID: <19980517140613.B18195@math.fu-berlin.de> Date: Sun, 17 May 1998 14:06:13 +0200 From: Felix von Leitner To: axp-list@redhat.com, linux-kernel@vger.rutgers.edu, tar-bugs@gnu.ai.mit.edu Subject: Patch to speeds up tar on Sparc-Linux (and Alpha-Linux?) Mail-Followup-To: axp-list@redhat.com, linux-kernel@vger.rutgers.edu, tar-bugs@gnu.ai.mit.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.91.1i The problem is that tar does a getpwnam for all files in a tar file. tar caches the last name it looked up, but does not do this if the lookup failed (as for most foreign tarballs), and on SparcLinux (and maybe Alpha-Linux? There were complains on how slow tar was there, too) this means reading the whole passwd. In our university, this means some 60k. See the difference: $ time tar xzf /tmp/mutt-0.92.8i.tar.gz 26.44s user 1.50s system 98% cpu 28.309 total $ rm -rf mutt-0.92.8i $ time ./tar xzf /tmp/mutt-0.92.8i.tar.gz 2.05s user 0.69s system 95% cpu 2.854 total $ Please apply the following patch to tar-1.12/src/names.c, it extends the caching to UIDs on which the lookup failed. We should probably extend the caching to all UIDs that were found so far. Felix --- names.c Tue Apr 22 07:35:50 1997 +++ names.c.new Sun May 17 13:58:08 1998 @@ -48,6 +48,9 @@ static uid_t cached_uid; /* valid only if cached_uname is not empty */ static gid_t cached_gid; /* valid only if cached_gname is not empty */ +int lookup_failed = 0; +int glookup_failed = 0; + /*------------------------------------------. | Given UID, find the corresponding UNAME. | `------------------------------------------*/ @@ -111,12 +114,18 @@ passwd = getpwnam (uname); if (passwd) { + lookup_failed = 0; cached_uid = passwd->pw_uid; strncpy (cached_uname, uname, UNAME_FIELD_SIZE); } - else + else { + lookup_failed = 1; + strncpy (cached_uname, uname, UNAME_FIELD_SIZE); return 0; + } } + if (lookup_failed) + return 0; *uidp = cached_uid; return 1; } @@ -140,9 +149,14 @@ cached_gid = group->gr_gid; strncpy (cached_gname, gname, GNAME_FIELD_SIZE); } - else + else { + glookup_failed = 1; + strncpy (cached_gname, gname, GNAME_FIELD_SIZE); return 0; + } } + if (glookup_failed) + return 0; *gidp = cached_gid; return 1; }