Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: One more heap optimization trick for zsh < 5.2



On Jun 11,  9:40am, Sebastian Gniazdowski wrote:
}
} > It might have something to do with retaining the old copy
} > of the function body until the call stack unwinds and it can safely
} > be freed; a large value for $argv would therefore also hang around
} > (two copies of it) for all of that time.
} 
} That's apparently a hit. I attach two test files.

I modified one of the tests to simply print $funcstack in each of the
possible function calls on one pass (repeat 1).  That yields:

Normal autoload:
aload_fun_main /home/schaefer/Mail/detach.dir/aload.zsh2.txt
aload_fun aload_fun_main /home/schaefer/Mail/detach.dir/aload.zsh2.txt

Special autoload:
aload_fun_main (eval) aload_fun_main /home/schaefer/Mail/detach.dir/aload.zsh2.txt
aload_fun (eval) aload_fun aload_fun_main (eval) aload_fun_main /home/schaefer/Mail/detach.dir/aload.zsh2.txt

More special autoload:
--reload-and-run aload_fun_main /home/schaefer/Mail/detach.dir/aload.zsh2.txt
aload_fun_main --reload-and-run aload_fun_main /home/schaefer/Mail/detach.dir/aload.zsh2.txt
--reload-and-run aload_fun aload_fun_main --reload-and-run aload_fun_main /home/schaefer/Mail/detach.dir/aload.zsh2.txt
aload_fun --reload-and-run aload_fun aload_fun_main --reload-and-run aload_fun_main /home/schaefer/Mail/detach.dir/aload.zsh2.txt


So the "more special" version makes twice as many function calls as the
"special" one, and both of the latter have deeper call stacks than the
"normal" one.  From your timings, "more special" takes about twice as
long as either, which sort of makes sense given double the number of
calls.

However, that doesn't explain why it remains slow in the n-list loop. I
again changed aload_fun_main (fbody1) to use "repeat 2" and it does not
show any extra call stack depth on the second pass, so it's not that it
is e.g. somehow finding the "wrong" aload_fun body.



Messages sorted by: Reverse Date, Date, Thread, Author