diff options
| author | Sean Kurtz <seankurtz75@gmail.com> | 2026-11-24 11:52:12 -0600 |
|---|---|---|
| committer | Sean Kurtz <seankurtz75@gmail.com> | 2026-11-24 11:52:12 -0600 |
| commit | 2b257338481007b88331ae445b26ff99bdbf8977 (patch) | |
| tree | d5878c980bbeeffd02f17faf556854e599bd4251 /bench | |
| parent | d60ce596e6f4ecd62ada6be0916caea22c75e0a8 (diff) | |
| download | zash-2b257338481007b88331ae445b26ff99bdbf8977.tar.gz | |
docs: humanize the markdown docsdocs/startup-probe
Plain sentences where the prose had decorative bold lead-ins, em dashes
and one-line closers. Claims, numbers and commands are unchanged, except
two corrections that the startup probe settled: README said the remaining
z/OS gap was the price of the address mode, and DESIGN's open question on
`a | b &` said the gain depended on the address mode. Both are the 64-bit
C run-time, not the address mode.
Diffstat (limited to 'bench')
| -rw-r--r-- | bench/README.md | 139 |
1 files changed, 72 insertions, 67 deletions
diff --git a/bench/README.md b/bench/README.md index 0ff147f..8bbb8fe 100644 --- a/bench/README.md +++ b/bench/README.md @@ -19,21 +19,21 @@ sh bench/run.sh "$(pwd)/zash" /bin/sh bash zsh oksh Three things about that line are not optional: -- **Every shell is an absolute path.** `run.sh` changes to a work - directory before running anything, so a relative `./zash` prints `n/a` - in every row. -- **`_BPXK_AUTOCVT=ON`.** The scripts are tagged ISO8859-1. Without it, +- Every shell is an absolute path. `run.sh` changes to a work directory + before running anything, so a relative `./zash` prints `n/a` in every + row. +- `_BPXK_AUTOCVT=ON`. The scripts are tagged ISO8859-1. Without it, /bin/sh and the other shells cannot read them and fail with `FSUM7332 syntax error: got ), expecting Newline`. zash is not affected: it converts by tag itself. -- **`TMPDIR` on a writable filesystem.** That is where the work - directory goes. +- `TMPDIR` on a writable filesystem. That is where the work directory + goes. A full run takes about a minute and is best run detached (`nohup ... > bench.txt 2>&1 </dev/null &`); otherwise an interrupted `ssh` session takes the run with it. -The times are **CPU seconds, user + sys, children included**, so they do +The times are CPU seconds, user + sys, children included, so they do not include wall-clock start-up. See [Start-up is not in these numbers](#start-up-is-not-in-these-numbers). @@ -41,8 +41,8 @@ numbers](#start-up-is-not-in-these-numbers). Measured on the CBT z/OS system with IBM Open XL C/C++ 2.1 (clang 18.1.8), the same compiler and the same source in both modes, so the -only variable is the width the C run-time is built at — not the address -mode itself; [an assembler program with no C run-time](#is-it-the-address-mode-or-the-c-runtime) +only variable is the width the C run-time is built at. The address mode +is not a variable: [an assembler program with no C run-time](#is-it-the-address-mode-or-the-c-runtime) starts in 0.8 ms at either width. | | `-m64` | `-m32` | ratio | @@ -52,33 +52,34 @@ starts in 0.8 ms at either width. | the same, 64 MB touched | 28.2 ms | 27.7 ms | 1.0× | | start a trivial program | 29.5 ms | 1.1 ms | 27× | -Two separate costs, and they behave differently: +Two costs, and they behave differently: -- **A fixed penalty for being 64-bit.** About 4 ms per `fork()` and - about 28 ms per program start, paid whatever the program does and - whatever storage it holds. A ten-line program that returns 0 pays it. -- **A per-byte copy cost that both modes pay.** Roughly 0.4 ms per MB of +- A fixed penalty for being 64-bit. About 4 ms per `fork()` and about + 28 ms per program start, paid whatever the program does and whatever + storage it holds. A ten-line program that returns 0 pays it. +- A per-byte copy cost that both modes pay. Roughly 0.4 ms per MB of touched private storage, identical at `-m64` and `-m32`. At 64 MB it dominates and the address mode stops mattering. -The 28 ms is not program load: a 28 KB program and a 900 KB program cost -the same, and the sticky bit changes nothing (29.4 ms either way). It is -not I/O either — the process uses under 1 ms of CPU in that time and -simply waits. It is not XPLINK: Open XL spells the three modes `-m64` -(64-bit XPLINK), `-m32` (32-bit XPLINK) and `-m32n` (32-bit non-XPLINK), -and the two 32-bit ones both start in about 1 ms. It is not the 64-bit -address space either: an assembler program with no C run-time starts in -0.8 ms at 31 bits *and* at 64 bits (see [Is it the address mode or the -C runtime?](#is-it-the-address-mode-or-the-c-runtime)). Nor is it zash's -own storage — LE reports 50 KB of user heap, 94 KB of library heap and -1 MB of stack for `zash -c :`, so a fork has almost nothing to copy. +Program load is ruled out: a 28 KB program and a 900 KB program cost the +same, and the sticky bit changes nothing (29.4 ms either way). I/O is +ruled out too: the process uses under 1 ms of CPU in that time and +simply waits. XPLINK is ruled out by the same programs built at the +other two modes Open XL spells, `-m32` (32-bit XPLINK) and `-m32n` +(32-bit non-XPLINK); both start in about 1 ms. The address space is +ruled out by the assembler probe: no C run-time, and it starts in 0.8 ms +at 31 bits *and* at 64 bits (see [Is it the address mode or the +C runtime?](#is-it-the-address-mode-or-the-c-runtime)). zash's own +storage is too small to matter: LE reports 50 KB of user heap, 94 KB of +library heap and 1 MB of stack for `zash -c :`, so a fork has almost +nothing to copy. What is slow is Language Environment starting in 64-bit mode. The [LE Programming Guide for 64-bit](https://www.ibm.com/docs/en/zos) puts -it plainly — "the creation and termination of that HLL environment -multiple times is needlessly inefficient" — and offers PreInit -(`CELQPIPI`) to create it once and reuse it, which is no help to a shell -that starts, runs and exits. On this machine that creation costs 28 ms +it plainly: "the creation and termination of that HLL environment +multiple times is needlessly inefficient". It offers PreInit +(`CELQPIPI`) to create that environment once and reuse it, which is no +help to a shell that starts, runs and exits. On this machine that creation costs 28 ms of wall time at 64 bits (about 1 ms at 31), and no option moves it. For scale, the same measurement on `/bin/sh` (z/OS sh, AMODE 31) is 2.1 ms @@ -145,21 +146,20 @@ time sh -c 'i=0; while [ $i -lt 100 ]; do ./t64; i=$((i+1)); done' time sh -c 'i=0; while [ $i -lt 100 ]; do ./t32; i=$((i+1)); done' ``` -Two traps in getting this right, both of which produced wrong answers -here first: +Two traps, both of which produced wrong answers here first: -- **Check the build, not the flag.** `-m31` is rejected; `-m32` is the +- Check the build, not the flag. `-m31` is rejected; `-m32` is the spelling that works, and `file` prints `amode=31` for the result. `ibm-clang -print-targets` lists `systemz32` as a registered target. -- **Make sure the probe measures what you think.** `return p ? 0 : 0;` - lets the compiler delete the allocation, and the "8 MB" row then reads - the same as "0 MB". Touch the memory after the loop. +- Make sure the probe measures what you think. `return p ? 0 : 0;` lets + the compiler delete the allocation, and the "8 MB" row then reads the + same as "0 MB". Touch the memory after the loop. ## Is it the address mode or the C runtime? It is the C runtime, and the address mode is free. The probe is the -same empty program written in HLASM — no LE, no XPLINK, just a return -code and `SVC 3` (EXIT) — at each width, against the C version: +same empty program written in HLASM, with no LE and no XPLINK, just a +return code and `SVC 3` (EXIT), at each width, against the C version: 100 starts each, three rounds, the same numbers every round: @@ -174,22 +174,23 @@ code and `SVC 3` (EXIT) — at each width, against the C version: A 64-bit address space costs nothing: `tiny64` loads above the bar and starts as fast as `tiny31`. The 28 ms arrives with LE at 64 bits and only with it, and the 31-bit LE start is about 1 ms. (The 32-bit C rows -read 1.0–1.1 ms in an earlier session; the absolute figures drift, the +read 1.0 to 1.1 ms in an earlier session; the absolute figures drift, the comparison holds.) -The `fork()` penalty was not split the same way — an assembler `fork()` -probe has not been written — but it is the cheapest explanation of a -fixed 4 ms that appears only in 64-bit children: the child re-creates -the enclave the parent had. +The `fork()` penalty was not split the same way, since no assembler +`fork()` probe exists, but it is the cheapest explanation of a fixed +4 ms that appears only in 64-bit children: the child re-creates the +enclave the parent had. -The probe in full — HLASM source, build lines, the loop — and the -follow-ups it leaves open are in -[notes/investigation.md](../notes/investigation.md). +The probe in full, with its HLASM source, build lines and loop, is in +[notes/investigation.md](../notes/investigation.md); that file also +lists what it leaves open. ## LE run-time options: no measurable effect The obvious suspect for a 4 ms `fork()` and a 28 ms start is LE's own -sizing — `HEAP64`, `HEAPPOOLS64`, `STACK64`. It is not. +sizing: `HEAP64`, `HEAPPOOLS64`, `STACK64`. None of them moves the +number. | `_CEE_RUNOPTS` | fork | start | | --- | --- | --- | @@ -212,7 +213,7 @@ storage actually used, in case a future LE release behaves differently: _CEE_RUNOPTS='RPTOPTS(ON),RPTSTG(ON)' ./zash -c : 2>rpt.txt ``` -The report lists each option, its value, and where it was set — +The report lists each option, its value, and where it was set: installation default, `CELQUOPT`, or the `_CEE_RUNOPTS` override. Both reports go to the message file, stderr by default. `_CEE_RUNOPTS` is inherited, so any LE child of the process prints its own report; `-c :` @@ -233,8 +234,9 @@ interactive session. Compare it with `time`, not with `make bench`. ## Address mode and the 31-bit build zash is a 31-bit (AMODE 31) XPLINK program, which is what the z/OS -Makefile targets build. It used to be 64-bit; the costs above are what -that choice cost, and they were the whole of the remaining z/OS gap. +Makefile targets build. It used to be built 64-bit; the costs above are +what that choice cost, and they accounted for the whole of the remaining +z/OS gap. The same sources build at either width with the same compiler: @@ -263,9 +265,9 @@ Nothing else moves: `report` 0.18 → 0.16, `deploy` 0.15 → 0.14, `spawn` 1.17 → 1.15. Every row is the same or slightly better, because a smaller address space costs nothing. -Two things had to be settled before 31-bit could ship, and both are: +Two things had to be settled before 31-bit could ship: -1. **The catalog search.** It used to need `zos_csi.s`, an `AMODE 64` +1. The catalog search. It used to need `zos_csi.s`, an `AMODE 64` routine that switched modes with `SAM31`/`SAM64` around IGGCSI00 and passed a `__malloc31` block. At 31-bit the C code calls IGGCSI00 directly, with `fetch()` and `#pragma linkage(..., OS_UPSTACK)`, and @@ -274,9 +276,9 @@ Two things had to be settled before 31-bit could ship, and both are: check (use `OS_UPSTACK`), and the name given to `fetch()` must be an ordinary literal, because `__fetch_a` converts it and EBCDIC bytes get converted twice. -2. **Address space.** A 31-bit shell is limited to storage below 2 GB. - Ample for a shell, not for `x=$(<hugefile)`, which now fails with - "out of memory" rather than growing past it. +2. Address space. A 31-bit shell is limited to storage below 2 GB, which + is plenty for a shell but not for `x=$(<hugefile)`: that now fails + with "out of memory" rather than growing past it. 32-bit pointers also shrink the nodes, arenas and hash tables, which is why no row got worse. @@ -285,7 +287,7 @@ why no row got worse. What to run when a number here is surprising. -**Which address mode is this program, and does every CSECT agree?** +### Which address mode is this program, and does every CSECT agree? ```sh file ./zash # amode=31 or amode=64 @@ -297,9 +299,10 @@ grep -nE 'AMODE|RMODE|ENTRY POINT' zash.amblist assembler CSECT left to check, so the listing should show one member and `AMODE 31` throughout. -**What storage does the program actually use?** This is the input to -fork cost, and the reason a big shell would fork more slowly than a -small one: +### What storage does the program actually use? + +This is the input to fork cost, and the reason a big shell forks more +slowly than a small one: ```sh _CEE_RUNOPTS='RPTSTG(ON)' ./zash -c : 2>rpt.txt @@ -310,15 +313,17 @@ RPTSTG reports heap and stack use per enclave; RPTOPTS reports every run-time option, its value, and where it was set. Both go to the message file, stderr by default. -**Where is the shell spending CPU?** `dbx` works on z/OS and is the -target of `make zos-debug` and `make zos-dbx`. Note that the costs above -are not CPU — nearly all of the 28 ms is a wait — so a profile taken -inside zash will not show them. That is why the probes here are separate -programs rather than shell built-ins. +### Where is the shell spending CPU? + +`dbx` works on z/OS and is the target of `make zos-debug` and +`make zos-dbx`. The costs above are not CPU: nearly all of the 28 ms is +a wait, so a profile taken inside zash will not show them. That is why +the probes here are separate programs rather than shell built-ins. + +### What did the compiler emit? -**What did the compiler emit?** `ibm-clang -S` gives assembly, and -`-fsave-optimization-record` (or `-Rpass=`) gives clang's remarks about -what was and was not optimised. +`ibm-clang -S` gives assembly, and `-fsave-optimization-record` (or +`-Rpass=`) gives clang's remarks about what was and was not optimised. ## Reading the two tables @@ -328,5 +333,5 @@ the third-party oksh port's own breakage (`echo hi | cat` prints garbage there), not anything zash did. Rows that create processes move by a few hundredths between runs, and -the fork-heavy ones move more, so treat a 0.01–0.02 difference as noise +the fork-heavy ones move more, so treat a 0.01 to 0.02 difference as noise and re-run before believing it. |
