From owner-freebsd-hackers Wed Jul 21 4:28: 3 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from alcanet.com.au (border.alcanet.com.au [203.62.196.10]) by hub.freebsd.org (Postfix) with ESMTP id 7956914DF5 for ; Wed, 21 Jul 1999 04:27:55 -0700 (PDT) (envelope-from jeremyp@gsmx07.alcatel.com.au) Received: by border.alcanet.com.au id <40326>; Wed, 21 Jul 1999 21:06:48 +1000 Date: Wed, 21 Jul 1999 21:25:07 +1000 From: Peter Jeremy Subject: Re: speed of file(1) In-reply-to: <86u2qy2utc.fsf@not.demophon.com> To: will@iki.fi Cc: hackers@FreeBSD.ORG Message-Id: <99Jul21.210648est.40326@border.alcanet.com.au> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Ville-Pertti Keinonen wrote: >jeremyp@gsmx07.alcatel.com.au (Peter Jeremy) writes: >> I can't believe these figures. Based on the figures below, maybe I was overly hasty in this statement. The changes between 2.x and 3.x magic files have far more impact than I would have expected. >What are your results, then? All timings with everything cached (although the 386 only has 8MB which limits the cacheability). For the 2.2.5 systems, I give timings with both the 2.2.5 magic and the 4.0 magic (which is the same as 3.2-RELEASE, in /tmp). i386SX-25 running 2.2.5 (roughly as posted earlier): % /usr/bin/time file src/Z/dhcp-2.0b1pl26.tar.gz src/Z/dhcp-2.0b1pl26.tar.gz: gzip compressed data, deflated, last modified: Thu Jan 1 10:00:00 1970, os: Unix 2.82 real 1.92 user 0.84 sys % /usr/bin/time file -m /tmp/magic src/Z/dhcp-2.0b1pl26.tar.gz src/Z/dhcp-2.0b1pl26.tar.gz: gzip compressed data, deflated, last modified: Thu Jan 1 10:00:00 1970, os: Unix 4.05 real 2.67 user 1.23 sys 486DX2-50 running 2.2.5: % /usr/bin/time file src/Z/dhcp-3.0-alpha-19990423.tar.gz src/Z/dhcp-3.0-alpha-19990423.tar.gz: gzip compressed data, deflated, last modified: Thu Jan 1 10:00:00 1970, os: Unix 1.43 real 0.96 user 0.38 sys % /usr/bin/time file -m /tmp/magic src/Z/dhcp-3.0-alpha-19990423.tar.gz src/Z/dhcp-3.0-alpha-19990423.tar.gz: gzip compressed data, deflated, last modified: Thu Jan 1 10:00:00 1970, os: Unix 2.15 real 1.62 user 0.44 sys PII-266 running 4.0-CURRENT: % /usr/bin/time file src/Z/dhcp-1.4.0p6.tar.gz src/Z/dhcp-1.4.0p6.tar.gz: gzip compressed data, deflated, last modified: Wed Mar 3 20:57:52 1999, os: Unix 0.13 real 0.09 user 0.03 sys When I profile file in a slow system (like a 386 or 486), there is an obvious performance bottleneck: The problem is the memcpy() invoked from fgets(). The only solution would seem to be to mmap() magic and parse it, rather than using fgets() to read it. This bottleneck will also be far more obvious on bandwidth-starved systems (like 386SX and 486DX2/4), whereas virtually the whole thing fits into the L2 cache on my P-II. Peter To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message