From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15940 invoked by alias); 9 Feb 2015 02:20:29 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 34477 Received: (qmail 16544 invoked from network); 9 Feb 2015 02:20:26 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=CoYIqc8G c=1 sm=1 tr=0 a=FT8er97JFeGWzr5TCOCO5w==:117 a=kj9zAlcOel0A:10 a=q2GGsy2AAAAA:8 a=oR5dmqMzAAAA:8 a=-9mUelKeXuEA:10 a=0HtSIViG9nkA:10 a=WkmlGAZc5A1xDDxWLG4A:9 a=CjuIK1q_8ugA:10 From: Bart Schaefer Message-id: <150208182012.ZM14199@torch.brasslantern.com> Date: Sun, 08 Feb 2015 18:20:12 -0800 In-reply-to: <150208122744.ZM5447@torch.brasslantern.com> Comments: In reply to Bart Schaefer "Re: Performance of _store_cache and _retrieve_cache" (Feb 8, 12:27pm) References: <54D78CA8.7010802@thequod.de> <150208122744.ZM5447@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: "Zsh Hackers' List" Subject: Slow parsing of large array assignments MIME-version: 1.0 Content-type: text/plain; charset=us-ascii 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.