NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/39759: NetBSD awk (nawk) is 14 times slower than GNU awk



>Number:         39759
>Category:       bin
>Synopsis:       NetBSD awk/nawk is 14 times slower than GNU awk
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 18 10:00:00 +0000 2008
>Originator:     cheusov%tut.by@localhost
>Release:        NetBSD 4.0_STABLE
>Organization:
>Environment:
System: NetBSD chen.chizhovka.net 4.0_STABLE NetBSD 4.0_STABLE (GENERIC) #2: 
Wed Sep 24 23:57:38 EEST 2008 
cheusov%chen.chizhovka.net@localhost:/srv/obj/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
Th following simple script shows that NAWK is unacceptably slower than
GNU awk.

    ~/tmp/1.awk:
    {
        accu = accu "\n" $0
    }
    NF == 0 {
        print accu
        accu = ""
        next
    }

0 ~>time -p gawk -f ~/tmp/1.awk /srv/pkgsrc/pkg_src_summary.txt > /dev/null 
real 35.08
user 14.49
sys 20.58
0 ~>time -p mawk -f ~/tmp/1.awk /srv/pkgsrc/pkg_src_summary.txt > /dev/null 
real 68.26
user 27.47
sys 40.79
0 ~>time -p nbawk -f ~/tmp/1.awk /srv/pkgsrc/pkg_src_summary.txt > /dev/null 
real 263.79
user 202.20
sys 61.59
0 ~>

nbawk is wip/netbsd-awk compiled for Linux.
Under NetBSD-4 nawk works the same way - more than 12 times slower.

/srv/pkgsrc/pkg_src_summary.txt is a summary about all packages from
pkgsrc source tree, generated by pkg_src_summary(1) utility
from wip/pkg_summary-utils package.
It is ~50Mb text file 
    http://www.mova.org/~cheusov/pub/pkg_src_summary.txt

I didn't run profiler but it seems to me that nawk is slower
because its string concatenation ALWAYS run malloc/memcpy/free
functions. This is extremly inefficient.

See run.c:cat function

>Fix:

Unknown


Home | Main Index | Thread Index | Old Index