diff options
| author | Sean Kurtz <seankurtz75@gmail.com> | 2026-11-25 17:50:59 -0600 |
|---|---|---|
| committer | Sean Kurtz <seankurtz75@gmail.com> | 2026-11-25 17:50:59 -0600 |
| commit | 4eba9006c8f36164070690e34e9be10f94d39221 (patch) | |
| tree | fe95f9118c77b38fc06c5ebcc49cd7e1d2dda2cc /src/exec.c | |
| parent | 0ebef9da03f1952e8d0189a48cd7b946a7369f4f (diff) | |
| download | zash-perf/fork-fastpath.tar.gz | |
perf: temporary fork-path ablation switchesperf/fork-fastpath
Diffstat (limited to 'src/exec.c')
| -rw-r--r-- | src/exec.c | 23 |
1 files changed, 20 insertions, 3 deletions
@@ -511,6 +511,18 @@ void unwind_restore(const unwind *u) { /* ---- processes ------------------------------------------------------- */ /** + * @brief Temporary experiment: bit mask of fork-path steps to skip. + */ +int perf_ablate(void) { + static int bits = -1; + if (bits < 0) { + const char *s = getenv("ZASH_FORK_ABLATE"); + bits = s ? atoi(s) : 0; + } + return bits; +} + +/** * @brief fork() a copy of the shell. * * The child is a subshell: it forgets the parent's jobs and traps, and @@ -520,7 +532,8 @@ void unwind_restore(const unwind *u) { * raises an error. */ pid_t fork_shell(void) { - flush_all(); + if (!(perf_ablate() & 4)) + flush_all(); (void)shell_pid(); /* fix $$ before the pid changes */ pid_t pid = fork(); if (pid < 0) @@ -530,8 +543,10 @@ pid_t fork_shell(void) { stat_spawns = stat_forks = 0; if (job_launching) job_child_setup(); /* while SIGTTOU is still ignored */ - jobs_forget(); - trap_reset_child(); + if (!(perf_ablate() & 1)) + jobs_forget(); + if (!(perf_ablate() & 2)) + trap_reset_child(); } else { stat_forks++; if (job_launching) @@ -544,6 +559,8 @@ pid_t fork_shell(void) { * @brief Run a command as the whole remaining life of this (forked) process. */ [[noreturn]] static void child_eval(node *n) { + if (perf_ablate() & 8) + _exit(0); jmploc jl; if (setjmp(jl.buf) == 0) { exc_handler = &jl; |
