Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
the source of slow large for loops
- X-seq: zsh-workers 29172
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxx>
- Subject: the source of slow large for loops
- Date: Sat, 7 May 2011 19:00:17 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=gJUZStPKIrh93QyiA/IR2e8GJ7Kc5wcWKYFMbGq1sdY=; b=OYSUBV7SfwVdVoW1k1ofQD1gWtFoZ2zvY4cf14eyli/hA2yAPb9m8o6RQ21gnZAKDj ssldMo+c1VkNip5APtE9m0BvCV2EndIEv2GfMAS9lGL8C71S+okshnvelRxqks9Wrgll /VIuMxazEK1kvoVALuPCWj4vARWAb11x856Ng=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=UfoTFfiqpV7OhYBly8fbApqIwK1fYOJg7brW7uoU6mIOXC45qdWOYMAEjV8hLSSb4q j49M05XYu4sbqzoGCkgTLNvs/37OAouCQInF0li4VS9zcDnDMOl4FlXtSAMtLIIRTuSU N0wE+ljX2/d+rre9VbFB3Tq9BD62cWFJfLh3I=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
I don't know if anyone looked into why things like
for i in {1..700000}; do true; done
is extremely slow in zsh, so I did now. Turns out zhalloc is extremely
slow, and for the above loop, one particular line runs 12049901132
times according to gcov. (It takes around 10 minutes). If I add early
returns of malloc() and realloc() to zhalloc and hrealloc, the loop
runs in 3 seconds (but leaks a couple of hundred megabytes memory).
This is mostly a FYI thing, not really intending to do anything about
it or expecting anything, but I've always wondered where the slowness
was and now I know. :)
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author