hi there,

i just had subversion complain about a broken pipe while piping its output
through awk straight to head [1]. i decided to add a switch to head which will
tell it to never close a pipe unless the input has stopped [2].

of course this will produce massive overhead, but some people might find this
behaviour usefull. here's a simple benchmark:

`time hd test_file | head`:
=>
hd test_file  0,00s user 0,00s system 89% cpu 0,004 total
head  0,00s user 0,00s system 55% cpu 0,004 total


vs.

`time hd test_file | head -k`:
=>
hd test_file  3,28s user 0,03s system 95% cpu 3,465 total
head -k  0,04s user 0,02s system 1% cpu 3,465 total

test_file was created using:
`dd if=/dev/random bs=1m count=5 of=test_file`

there's probably a much more efficient way of discarding the input without
closing the pipe unless the input ceased. it's just a 5 minute hack in order to
see if people find the idea useful or not. ;)

cheers.
alex

[1] `http://people.freebsd.org/~arundel/scripts/whodid2.sh ls`
[1] http://people.freebsd.org/~arundel/patches/head.diff

-- 
a13x
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"

Reply via email to