From: Bart Schaefer <schaefer@brasslantern.com>
To: "Zsh Hackers' List" <zsh-workers@zsh.org>
Subject: Slow parsing of large array assignments
Date: Sun, 08 Feb 2015 18:20:12 -0800 [thread overview]
Message-ID: <150208182012.ZM14199@torch.brasslantern.com> (raw)
In-Reply-To: <150208122744.ZM5447@torch.brasslantern.com>
On Feb 8, 12:27pm, Bart Schaefer wrote:
}
} The slowdown here appears to be with compiling the source'd file into
} the internal wordcode format before executing it. Even dumping the
} whole assignment as a single string and then using "eval" on that, is
} faster than allowing "source" to parse the words directly. We may
} want to dig further into why that is the case.
The "slow" routine is parse.c:par_nl_wordlist(), which calls zshlex()
repeatedly [once for every word in the array]. This is slower when
reading from a file than when reading from a string in memory, which
explains the difference between "source" and "eval" for me.
It's also a lot slower than bufferwords(), which implements the (z)
flag for parameter splitting.
Finally, par_nl_wordlist() in the current revision of zsh seems to take
longer than in 4.2.0 or 5.0.7 for the same input.
Over 10 runs I get these average times sourcing a file that assigns
approximately 55000 words to an array:
zsh 4.2.0: 3.91s
zsh-5.0.7 (release version): 4.85s
zsh-5.0.7-289-g7d15b9a: 7.47s
I believe the two zsh-5.0.7 were compiled with identical flags, though
the 5.0.7 binary is stripped; I don't know about the old 4.2.0. If I
re-compile with -O in CFLAGS, g7d15b9a speeds up to 4.95s average.
next prev parent reply other threads:[~2015-02-09 2:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-08 16:19 Performance of _store_cache and _retrieve_cache Daniel Hahler
2015-02-08 18:27 ` Daniel Hahler
2015-02-08 19:14 ` Bart Schaefer
2015-02-08 20:27 ` Bart Schaefer
2015-02-09 2:20 ` Bart Schaefer [this message]
2015-05-23 1:10 ` Regression with completion cache (was: Re: Performance of _store_cache and _retrieve_cache) Daniel Hahler
2015-05-27 22:10 ` Performance of _store_cache and _retrieve_cache Oliver Kiddle
2015-05-28 22:18 ` Bart Schaefer
2015-05-29 11:13 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=150208182012.ZM14199@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).