[Gllug] Bug in grep? Surely not ...
Peter Grandi
pg_gllug at gllug.for.sabi.co.UK
Tue Sep 20 14:29:49 UTC 2005
>>> On Tue, 20 Sep 2005 15:06:08 +0100, Richard Jones
>>> <rich at annexia.org> said:
rich> I have this rather large data file, and I want to get out
rich> just the non-zero rows: http://annexia.org/tmp/col4 [
rich> ... ] BUT if I redirect the output to a file, grep hangs
rich> consuming 100% CPU,
It is practically instantaneous here.
As a first step, check whether the 100% CPU consumption is user
or system CPU with 'vmstat 1'.
rich> I'm quite sure this can't _really_ be a bug in grep, but
rich> I'm at a loss to know where to look. [ ... ]
It is hard to imagine that it is a 'grep' because the output
file descriptor is set up by the shell, not 'grep', in either
case.
Perhaps something is wrong with the filesystem in which '/tmp'
is contained. So try to redirect output first to '/dev/null'
and then to a file on another filesystem/partition. Same for
input BTW, as that's on '/tmp' too.
As to my '/tmp', it is a 'tmpfs', but the same 'grep' is also
instantaneous here to '/var/tmp/costs', which is on my 'root'
filesystem.
rich> but strace shows its not doing anything at all.
Well, 'strace' only shows system calls -- if a program gets
stuck in a looping system call... :-)
You can also use GDB in attach mode to see exactly what the
'grep' is doing, or perhaps use 'ltrace' as an intermediate
detail solution.
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list