diff options
| author | Sean Kurtz <seankurtz75@gmail.com> | 2026-11-24 21:05:17 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-24 21:05:17 -0600 |
| commit | 4e2be21ad459e9622bfdb30f9daf04f547cdf86a (patch) | |
| tree | 974f91663a54f8791192b43567b421b590a6b443 | |
| parent | c0e48819c3077ccc020deb8b9ffe9de9911ab3d2 (diff) | |
| download | zash-4e2be21ad459e9622bfdb30f9daf04f547cdf86a.tar.gz | |
Wording pass on the 64-bit start-up write-up (#17)
* notes: plainer wording in the 64-bit start-up write-up
Same findings, less staging: no dash-as-connector, no bold cell, no
"not X but Y" contrast, and one space after a full stop like the rest
of the file. Also fixes "4-5 orders of magnitude" for a 5x difference.
* tests: clang-format spawn.c
| -rw-r--r-- | notes/investigation.md | 72 | ||||
| -rw-r--r-- | tests/tools/spawn.c | 4 |
2 files changed, 37 insertions, 39 deletions
diff --git a/notes/investigation.md b/notes/investigation.md index 33e251e..ee8aac0 100644 --- a/notes/investigation.md +++ b/notes/investigation.md @@ -93,8 +93,8 @@ the whole cost. the fork penalty is attributed to LE by inference (a fixed cost that appears only in 64-bit children), not by measurement. `BPX1FRK` is callable from HLASM at either AMODE; that is the next probe. -- Where inside LE the 28 ms goes: answered in §2 -- LE's POSIX start-up - path, and it is a wait, not work. +- Where inside LE the 28 ms goes: answered in §2, where the time turns + out to be spent waiting rather than working. - Why 31-bit LE costs 1 ms. Assumed to be the same enclave work at smaller sizes; not measured separately. @@ -104,12 +104,12 @@ made in one run are worth quoting. ## 2. Where the 28 ms goes: inside LE, and it is a wait -Answered as far as an ordinary user can: the cost is paid inside Language -Environment before the first instruction of `main`, ~1 ms of it is CPU -charged to the child, and the rest is time spent waiting on something -shared. Which shared thing is still open -- see the end of this section. +The cost is paid inside Language Environment, before the first +instruction of `main`. About 1 ms of it is CPU charged to the child and +the rest is time spent waiting on something shared; which shared thing is +still open below. That is as far as an ordinary user can get. -The probes are in `~/tmp/startup-probe2` on the box; `bench/le-init.sh` +The probes are in `~/tmp/startup-probe2` on the box. `bench/le-init.sh` reproduces the table below. ### Method @@ -134,8 +134,8 @@ reproduces the table below. | `main` returns, to exit | 720 µs | 467 µs | The 64-bit distribution is tight (min 28,429, max 29,220 µs over 20 -starts), so it is not a timer or an unlucky slice, and 27 of the 28 ms -are before `main` gets control. +starts), so the cost is systematic rather than one unlucky slice, and 27 +of the 28 ms are before `main` gets control. ### The same binary, two regimes @@ -150,14 +150,14 @@ child CPU, milliseconds per start): | `c32n` (`-m32n`) | 1.47 | 0.00 | | `c64` (`-m64`) | 5.83 | 1.00 | | `pr64` (`-m64`, `printf`) | 6.06 | 1.25 | -| `c64`, earlier in the same session | **30.45** | 1.25 | +| `c64`, earlier in the same session | 30.45 | 1.25 | So the 64-bit path costs about 4 ms over the 31-bit one on a machine that is otherwise idle, and 28 ms while something else is going on, with the -CPU charge unchanged at 1.0-1.25 ms in both cases. The other rows do not +CPU charge unchanged at 1.0-1.25 ms in both cases. The other rows do not move between the two regimes, and a 200-million iteration loop still -costs 391 ms of CPU while they do, so this is not the LPAR getting -slower: only this path is. +costs 391 ms of CPU while they do, so the LPAR did not get slower, only +this path did. ### It is a wait, and while it is slow it does not overlap @@ -166,18 +166,17 @@ wall, so most of the cost is spent off-processor. - Slow regime (30 ms): two children forked together both reach `main` after 54 ms, i.e. 2 × 28 ms, and 32 starts with 8 in flight give the - same 5.7 ms per start as one at a time. Serialized. + same 5.7 ms per start as one at a time. Serialized. - Quiet regime (5.8 ms): two `spawn` runs of 20 in parallel take 230 ms - where one run of 40 takes 246 ms. They overlap. + where one run of 40 takes 246 ms. They overlap. -Same code, same machine, so the shared resource has a queue that is -empty when the box is quiet and 4-5 orders of magnitude longer when it -is not. +Same code, same machine: the shared resource queues while the box is +busy and does not when it is quiet. ### What it is not -- Not the program. `int main(void) { return 0; }` and a battery of 15 - libc calls differ by ~0.2 ms; a single `printf` costs ~0.1 ms. The +- Not the program. `int main(void) { return 0; }` and a battery of 15 + libc calls differ by ~0.2 ms; a single `printf` costs ~0.1 ms. The battery's most expensive entry is `fork()` at 6.2 ms (see §1); `pthread_create` 269 µs, `getpwuid` 119 µs, `getpwnam` 62 µs, `setlocale(LC_ALL, "")` 13 µs, `tzset`, `dlopen(NULL)`, `getrlimit`, @@ -189,7 +188,7 @@ is not. environment, empty `LIBPATH`, a long `LIBPATH`, and five working directories (`/`, `/usr/lib`, `/etc`, `$HOME`, the probe directory) all give the same number. -- Not a run-time option. Taken one at a time from outside, 30 starts +- Not a run-time option. Taken one at a time from outside, 30 starts each: | `_CEE_RUNOPTS` | start | @@ -202,39 +201,38 @@ is not. | `RPTOPTS(OFF)` | 30.83 ms | Nothing to tune, and nothing to build into the program with a - `CELQUOPT` module. (`MSGLEVEL(0)` is not an option on this release: + `CELQUOPT` module. (`MSGLEVEL(0)` is not an option on this release: `CEE3611I`.) #### The `POSIX(OFF)` result that was wrong The first version of this measurement said `POSIX(OFF)` removes the cost -entirely (1.53 ms). It does not: properly applied, it makes no -difference. What happened is worth writing down, because it is easy to -repeat: `_CEE_RUNOPTS` was exported to the *parent*, which was an LE -program (the first `spawn`). With POSIX(OFF) in force, that program's -`execl` fails and every child exits 127 immediately -- 1.5 ms per failed -start, and a fork/exec loop that does not check exit status reports it as -a fast start. `_CEE_RUNOPTS` exported from a non-LE shell does reach the +entirely (1.53 ms). It does not. What happened, since the mistake is easy +to repeat: `_CEE_RUNOPTS` was exported to the *parent*, which was an LE +program (the first `spawn`). With POSIX(OFF) in force, that program's +`execl` fails and every child exits 127 immediately, at 1.5 ms per failed +start; a fork/exec loop that does not check exit status reports that as a +fast start. `_CEE_RUNOPTS` exported from a non-LE shell does reach the child, which is why the mistake looks like a working result from a shell -prompt. `tests/tools/spawn.c` now builds the child's environment by hand +prompt. `tests/tools/spawn.c` now builds the child's environment by hand and passes it to `execve`, since `putenv` after LE has initialized is not passed on either. ### Not settled - Which resource the wait is on, and what makes it 5× worse at times. - Everything is uncharged wall time on a shared queue. A DLL load from + Everything is uncharged wall time on a shared queue. A DLL load from the z/OS UNIX file system was ruled out only for the fixed part (`pr64` pays the same 6 ms with the same search); an SRB, a service address space, or the page-in of the 64-bit runtime remain candidates. `ps -A` shows no system address spaces to an ordinary user, z/OS `/proc/<pid>` has no `map`, `wchan` or `sysent`, and the z/OS UNIX syscall trace (`SIGTRACE` then `SIGDUMP`, - `le-debugging-ceea100_v3r2.txt:17792`) needs dump authority. So this + `le-debugging-ceea100_v3r2.txt:17792`) needs dump authority. So this needs the operator, or a quieter machine to compare against. -- Whether an APAR or PTF already covers it. Everything here is z/OS +- Whether an APAR or PTF already covers it. Everything here is z/OS 29.00 with LE as shipped; no older release was compared. -- The 4 ms `fork()`. From inside a 64-bit LE program it is 6.2 ms +- The 4 ms `fork()`. From inside a 64-bit LE program it is 6.2 ms against 0.7 ms from the same source at `-m32`, with an identical child. The HLASM `BPX1FRK` probe is still unwritten, and an AMODE 64 `BPX4FRK` attempt abended: it needs a 144-byte F8SA save area and a @@ -259,16 +257,16 @@ What to ask: a 64-bit start spends 4.5-28 ms before the first instruction of `main`, of which 1.0-1.25 ms is charged to the process; the rest is wall time that does not overlap between concurrent starts when it is at its worst, and it disappeared into 5.8 ms when the LPAR -went quiet while every other measurement on the machine stayed put. The +went quiet while every other measurement on the machine stayed put. The same program at `-m32` costs 1.5 ms, a 64-bit HLASM program with no LE costs 1.4 ms, and no `_CEE_RUNOPTS` option changes it, `POSIX(OFF)` -included. Is there a known serialization (a latch, a service request, a +included. Is there a known serialization (a latch, a service request, a page-in of the 64-bit runtime) in the 64-bit LE initialization path, and can it be traced or PTFed? ### For zash -Nothing to do. zash is 31-bit on z/OS on purpose (`-m32`, +Nothing to do. zash is 31-bit on z/OS on purpose (`-m32`, `Makefile:64`), which pays 1.4-1.8 ms of LE instead of 5.8 or 30 ms, and no run-time option, environment change or link option found here buys any of the 64-bit cost back. diff --git a/tests/tools/spawn.c b/tests/tools/spawn.c index d1924db..bff74ed 100644 --- a/tests/tools/spawn.c +++ b/tests/tools/spawn.c @@ -97,8 +97,8 @@ int main(int argc, char **argv) { return 1; } if (!WIFEXITED(status)) { - fprintf(stderr, "spawn: %s did not exit (status %d)\n", - argv[1], status); + fprintf(stderr, "spawn: %s did not exit (status %d)\n", argv[1], + status); return 1; } if (WEXITSTATUS(status) != 0) { |
