zsh-workers
 help / color / mirror / code / Atom feed
* Can ZWC be optimized, for lesser depths of recursive exec* calls?
@ 2017-07-20 15:41 Sebastian Gniazdowski
  2017-07-20 17:40 ` Bart Schaefer
       [not found] ` <etPan.5970eb83.495b9d04.6b4@AirmailxGenerated.am>
  0 siblings, 2 replies; 6+ messages in thread
From: Sebastian Gniazdowski @ 2017-07-20 15:41 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1875 bytes --]

Hello,
I've occurred a comment in exec.c, from year 2000:

 * Pipelines like the one above are executed by the functions in this file
 * which call each other (and sometimes recursively). The one above, for
 * example would lead to a function call stack roughly like:
 *
 *  execlist->execpline->execcmd->execwhile->execlist->execpline

This casts some light on attached profiling-stack-traces (OS X tool Instruments; images compressed by pngcrunch). The stack traces are very deep. I am pretty sure that the test script (ran by the Zsh controled by the profiler) doesn't do pipes.

So a conclusion can be made:

- Zsh code execution is emerging from from rich number of calls to exec.c functions,
- general-purpose or not-final calls are done, equilibrium is established, each Zsh script part finds its (convoluted) way to execsimple, prefork, addvars,
- like in Prolog (but maybe in reversed direction), where each theorem finds its top truths in many stages.

CPU time is dissipated over exec.c calls, profiling confirms this.

I'm trying to alter custom zcompile to limit the depth in case where there are no pipes. Can someone help with this? I can only state that execsimple() and Z_SIMPLE, WC_SUBLIST_SIMPLE are related. However, following comment:

 * Lists and sublists may also be simplified, indicated by the presence
 * of the Z_SIMPLE or WC_SUBLIST_SIMPLE flags. In this case they are only
 * followed by a slot containing the line number, not by a WC_SUBLIST or
 * WC_PIPE, respectively.

and some exec.c-reading hints, that the "not-following by WC_SUBLIST" means no-argumets for executed function, builtin, etc. So, if an entity has arguments, it will require to invoke another recursive execpline2, because execsimple() cannot be used. Is something possible here?

--  
Sebastian Gniazdowski
psprint /at/ zdharma.org

[-- Attachment #2: execpline2_a.png --]
[-- Type: image/png, Size: 121123 bytes --]

[-- Attachment #3: execpline2_b.png --]
[-- Type: image/png, Size: 101387 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-08-19  5:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-20 15:41 Can ZWC be optimized, for lesser depths of recursive exec* calls? Sebastian Gniazdowski
2017-07-20 17:40 ` Bart Schaefer
2017-08-19  5:06   ` Sebastian Gniazdowski
     [not found] ` <etPan.5970eb83.495b9d04.6b4@AirmailxGenerated.am>
2017-07-25  1:26   ` Sebastian Gniazdowski
2017-07-25  5:04     ` Bart Schaefer
2017-07-25  5:42       ` Sebastian Gniazdowski

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