zsh-workers
 help / color / mirror / code / Atom feed
* Caching array parameters' lengths
@ 2016-05-08 20:21 Mikael Magnusson
  0 siblings, 0 replies; only message in thread
From: Mikael Magnusson @ 2016-05-08 20:21 UTC (permalink / raw)
  To: zsh workers

I've pushed a branch (mikachu/badarrays) that tries to do this. There
are some things that don't work, all tests fail if you enable it
globally with asserts, and most parameter/array tests fail with the
results just being wrong regardless of asserts. The top two commits
add -c and -C to typeset to control if a parameter uses the cached
length, and whether the cached length is checked via assert,
respectively. In the cases where it does work, there is noticable
improvement:

% typeset -a a
% a=(i{1..1000000})
% time (repeat 5000; do : $a[-1]; done)
( repeat 5000; do; : $a[-1]; done; )  15.24s user 0.01s system 98% cpu
15.515 total

% typeset -ca a
% time (repeat 5000; do : $a[-1]; done)
( repeat 5000; do; : $a[-1]; done; )  0.03s user 0.00s system 89% cpu
0.040 total

And it does grab the correct element:
% time (repeat 5000; do echo $a[-1]; done)
...
i1000000
i1000000
i1000000
...
( repeat 5000; do; echo $a[-1]; done; )  0.04s user 0.01s system 91%
cpu 0.064 total

So if anyone feels like this is a worthwhile cause, and is less lost
than I am in the intricacies of parameter substitution code, feel free
to take a look.

Also, don't blame Daniel for any of this, he just split up my original
branch into separate commits when I looked into this last time, I'm
responsible for all the brokenness.

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-05-08 20:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-08 20:21 Caching array parameters' lengths Mikael Magnusson

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).