diff options
| author | Sean Kurtz <seankurtz75@gmail.com> | 2026-11-24 22:29:48 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-24 22:29:48 -0600 |
| commit | 98f0bc024df92868d04fc42313dd034f3968c511 (patch) | |
| tree | da56a42c64f92bbcbc69fadd696597e24ef5803a /notes | |
| parent | 4eeb68e37ca5703377d8bd9423a47af7d56d832a (diff) | |
| download | zash-98f0bc024df92868d04fc42313dd034f3968c511.tar.gz | |
bench: the 64-bit start-up cost was the runtime not being in the LPA (#20)
Adding the CELQ members of CEE.SCEERUN2 to the dynamic LPA takes a
trivial 64-bit start from 5.83 ms to 1.63 ms, the fork() cost from
4.20 ms to 0.10 ms, and /bin/zsh from 31.4 ms to 3.6 ms. The 27x
ratio this repo has been explaining since PR #15 was a system not
following IBM's own advice for the 64-bit runtime.
Diffstat (limited to 'notes')
| -rw-r--r-- | notes/investigation.md | 99 |
1 files changed, 71 insertions, 28 deletions
diff --git a/notes/investigation.md b/notes/investigation.md index a706ba0..07e6eee 100644 --- a/notes/investigation.md +++ b/notes/investigation.md @@ -109,27 +109,66 @@ TASKLIB, STEPLIB or JOBLIB, LPA, and last the linklist (`:1225`). How far this goes: module pages are shared once loaded, so it is not a DASD read per start, and 400 starts in a row all cost the same 5.6 ms. What it does mean is that every address space loads and relocates the -DLL for itself, which is work that can wait while the system is busy. The -31-bit runtime is equally linklist-only and still starts in 1 ms, so this -is not the whole 4 ms. +DLL for itself, which is work that can wait while the system is busy. +The 31-bit runtime is equally linklist-only and still starts in 1 ms, +which made this look like a partial explanation at best; it turned out to +be all of it (see below). -The test that settles it changes the system, so it needs the operator: -put the `CELQ` members into the LPALST, or copy them into a library that -is already there and add them with `SETPROG LPA,ADD`, then re-run -`build/zos-tools/spawn ./c64 40`. If a 64-bit start then matches a 31-bit -one, the load was the cost; if it does not, the wait is inside LE's -POSIX(ON) initialization talking to a single system service. +### Settled: it is the load + +The test above was run, and the load was the cost. Each module is put in +the dynamic LPA from the linklist library it already lives in, no LPALST +change needed (`CSV551I` reports `SUCCESSFUL: 1` for each): + +```text +SETPROG LPA,ADD,MODNAME=CELQLIB,DSNAME=CEE.SCEERUN2 +``` + +and the same for `CELQDCPP`, `CELQDEST`, `CELQDMNP`, `CELQDSNF`, +`CELQIOTD`, `CELQMCHK`, `CELQV004` and `IBMHV011`. `D PROG,LPA,MODNAME=CELQLIB` +now answers `D P CELQLIB 148C9011 148C9000 009CC6D0 023730D8`, about +10 MB resident, and the whole set is about 14 MB. + +What that changed, measured in one sitting (`build/zos-tools/spawn`, +40 starts, milliseconds per start; zsh from `bench/startup.sh`): + +| | before | after | +| --- | --- | --- | +| `c32` (`-m32`) | 1.61 | 1.61 | +| `c64` (`-m64`) | 5.83 (30.45 busy) | 1.63 | +| `pr64` (`-m64`, `printf`) | 6.06 | 1.79 | +| `zash` (`-m32`) | 1.33 | 1.37 | +| `/bin/zsh` (the 64-bit shell) | 31.42 | 3.60 | +| `fk3 0 100`, `fork()` + `wait()` at `-m64` | 4.20 | 0.10 | +| two 64-bit children forked together | 2 × 28 ms | 1.6 ms each, overlapping | +| 32 starts, 8 in flight | 27.5 | 1.60 | + +Every 64-bit number that used to be slow is now the 31-bit number, and +the child's CPU charge drops to zero with it: the 4 ms of `fork()` CPU +was the same load work, not a fork of the enclave. `zsh` is the +independent confirmation — it is a 64-bit program we did not write, and +its start went from 31.4 ms to 3.6 ms. `bash` and `oksh` carry no LE at +all and did not move. + +The gain does not survive an IPL: the dynamic LPA is rebuilt at every +IPL. Making it permanent is an operator step, one of: + +- add `CEE.SCEERUN2` to the LPALST and put the `CELQ` members in an + `IEALPAxx` list, or +- run the nine `SETPROG LPA,ADD` commands from a `COMMNDxx` member at + IPL. + +`zash` itself gains nothing, which is the point of building it 31-bit: +it was already at 1.3 ms and is not the program that pays this. ### Not settled -- The 4 ms `fork()`. No assembler `fork()` probe has been written, so - 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, 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. + smaller sizes; not measured separately. It is no longer interesting: + it is 1 ms either way. +- Why a linklist load of the 64-bit DLL costs 4-28 ms when the 31-bit + one costs under 1 ms from the same kind of library. With the LPA + answer in hand this is a question for IBM rather than for zash. Absolute figures drift between sessions and machines (the 32-bit C rows read 1.0 to 1.1 ms in an earlier run, 2.0 ms here); only comparisons @@ -139,8 +178,11 @@ made in one run are worth quoting. 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 rest is time spent waiting on something shared; what that shared +thing was is answered in [Where the 64-bit runtime is loaded +from](#where-the-64-bit-runtime-is-loaded-from) — it was the load of the +64-bit runtime itself. The measurements below were taken before that, +on a system where it was not LPA-resident. The probes are in `~/tmp/startup-probe2` on the box. `bench/le-init.sh` reproduces the table below. @@ -287,16 +329,17 @@ build/zos-tools/spawn ./c32 40 # z/OS 29.00: 1.5 ms wall, ~0 CPU build/zos-tools/spawn ./c64 40 # 5.8 ms wall, 1.25 ms CPU ``` -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 -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 -page-in of the 64-bit runtime) in the 64-bit LE initialization path, and -can it be traced or PTFed? +What to ask: before the runtime was made LPA-resident, a 64-bit start +spent 4.5-28 ms before the first instruction of `main`, of which +1.0-1.25 ms was charged to the process; the rest was wall time that did +not overlap between concurrent starts when it was at its worst. With the +`CELQ` members in the dynamic LPA the same start costs 1.6 ms and the +fork CPU drops to nothing, so the question for IBM narrows to: why does +loading `CELQLIB` from the linklist cost 4-28 ms per address space when +the 31-bit runtime costs under 1 ms from the same kind of library, and +why does that load not overlap between address spaces? A 64-bit HLASM +program with no LE costs 1.4 ms throughout, and no `_CEE_RUNOPTS` option +moved it, `POSIX(OFF)` included. ### For zash |
