[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
very long variable + parameter expansion = crazy cpu usage ?
From: |
Mike Frysinger |
Subject: |
very long variable + parameter expansion = crazy cpu usage ? |
Date: |
Sat, 9 Apr 2005 03:26:28 -0400 |
User-agent: |
KMail/1.8 |
i had some scripts that were acting up lately and i finally managed to track
it back to a very long varable + parameter expansion
i currently have a variable such that ${#var} ~= 2440. when i try to do
something like [[ -z ${var/*ccache*} ]], it takes an abnormal amount of time
and proceeds to use 100% of my cpu. when i say abnormal, i mean that i have
a 2.2gig amd64 with 2gigs of ram and this statement can easily take up ~20
seconds to complete when there's nothing else running on the system.
tested on Gentoo amd64/ppc with bash3 (plus the 16 patches available) and on
Gentoo ia64 with bash2 (plus the 7 patches available), and on Debian i386
with bash3 (no idea what patches it has though). all exhibit the same bug :(
an example:
$ export var=$(perl -e 'print "a" x 3000')
$ time [[ -z ${var/*ccache*} ]]
real 0m22.928s
user 0m22.031s
sys 0m0.008s
if i load up say zsh and try the same thing, the test is pretty much
instantaneous :(
-mike
- very long variable + parameter expansion = crazy cpu usage ?,
Mike Frysinger <=