Subject: Re: bin/17466: awk(1), awk vs. gawk
To: NetBSD Bugs and PR posting List <netbsd-bugs@NetBSD.ORG>
From: Greg A. Woods <>
List: netbsd-bugs
Date: 07/03/2002 13:10:24
[ On Wednesday, July 3, 2002 at 12:53:04 (+0200), Klaus Klein wrote: ]
> Subject: bin/17466: awk(1), awk vs. gawk
> 	Install a link `gawk' to `awk'.
> 	Unclear if gawk(1) should be adjusted to mention the awk(1)
> 	command name.

Hopefully gawk is not long for the NetBSD world.

I've been using The One True AWK (i.e. BWK's distribution of the latest
AWK) exclusively instead of GNU AWK (aka gawk) for over two years now in
all of my systems (the few problems with system and pkgsrc scripts have
been reported and are already fixed in the source tree).  It's smaller,
and faster, and far less buggy than the version of gawk still included
in NetBSD (I don't know if it's less buggy than the latest version, but
perhaps it is), and it's easily featureful enough for all the needs one
normally has of an AWK interpreter in the base system.

If you look in /usr/src/usr.bin/awk/ you'll find infrastructure already
present to build AWK, and the AWK sources are imported in /usr/src/dist.

Hopefully it'll be moved to /usr/src/bin -- AWK is small enough to be
static-linked, and on those systems where /usr is a separate filesystem
the benefits of having AWK in /bin are enormous, not to mention that
static-linking gives it much faster execution times for many uses too.

	$ file /bin/awk
	/bin/awk: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, not stripped
	$ size /bin/awk
	text    data    bss     dec     hex     filename
	166563  5976    4748    177287  2b487   /bin/awk

Unstripped it's just barely in the top ten binaries in /bin (i.e. if you
don't count multiple links to the same file, and a few other programs I
have that are not in the default NetBSD distribution, such as 'nc').

By comparison the dynamic-linked gawk-3.1.0 is even larger:

	$ size /usr/pkg/bin/gawk    
	text    data    bss     dec     hex     filename
	194859  5956    12808   213623  34277   /usr/pkg/bin/gawk

and static-linked it is, well, as big as you'd expect it to be I guess:

	$ size ./gawk
	text    data    bss     dec     hex     filename
	404990  13156   41836   459982  704ce   ./gawk



	$ time sh -c 'i=0; while [ $i -lt 1000 ] ; do /bin/awk "{}" < /dev/null; i=$(($i+1)); done'
	    7.38s real     0.99s user     1.76s system
	$ time sh -c 'i=0; while [ $i -lt 1000 ] ; do /usr/pkg/bin/gawk "{}" < /dev/null; i=$(($i+1)); done'
	   14.56s real     2.27s user     4.73s system
	$ time sh -c 'i=0; while [ $i -lt 1000 ] ; do ./gawk "{}" < /dev/null; i=$(($i+1)); done'
	    7.92s real     0.52s user     1.81s system

Welcome to the overhead of!  :-)

								Greg A. Woods

+1 416 218-0098;            <>;           <>
Planix, Inc. <>; VE3TCP; Secrets of the Weird <>