General z/OS UNIX · Reference

Put Your 64-Bit C Runtime (CELQ*) in the Dynamic LPA

Updated

If you build 64-bit C or C++ tools for z/OS UNIX, or run 64-bit shells and utilities like zash or /bin/zsh, you may have noticed a startup gap: a trivial 64-bit binary takes 6 ms to start on a quiet LPAR and up to 30 ms on a busy system, while the same program compiled 31-bit starts in about 1.5 ms.

When I measured this while building zash, the slowdown came from where the 64-bit C runtime DLLs are loaded from, not from the 64-bit address mode or Language Environment itself.

Where the time goes

To separate the 64-bit address space from the C runtime, I timed five minimal programs over repeated runs on z/OS:

  • tiny31 and tiny64: bare HLASM (R15=0, SVC 3), no LE, no XPLINK, no C library (tiny64 is RMODE 64, loaded above the bar).
  • c32 (ibm-clang -O2 -m32), c32n (-m32n, non-XPLINK), and c64 (-m64): all compiling int main(void) { return 0; }.
Program AMODE Runtime Per start
tiny31 (HLASM) 31 None 0.8 ms
tiny64 (HLASM) 64 None 0.8 ms
c32 (-m32) 31 LE, XPLINK 2.0 ms
c32n (-m32n) 31 LE, non-XPLINK 2.0 ms
c64 (-m64) 64 LE, XPLINK 29.4 ms

Those timings narrow the cause down:

  • tiny64 loads above the bar and exits in 0.8 ms, matching tiny31, which rules out the 64-bit address space and loader.
  • -m32 and -m32n start at the same speed (2.0 ms), which rules out XPLINK.
  • Changing _CEE_RUNOPTS (POSIX, TRAP, HEAPPOOLS64, STACK64, or RPTOPTS) did not change startup time by even a millisecond.
  • Instrumenting the first instruction of main() showed more than 27 ms elapsed before main() received control, and only about 1.25 ms of that was charged CPU. The rest was uncharged wait time that serialized when two 64-bit children started concurrently (2 × 28 ms).

Why it happens: CEE.SCEELPA is 31-bit only

Check whether the 64-bit runtime is in LPA on your LPAR:

D PROG,LPA,MODNAME=CELQLIB

On many z/OS systems, CEE.SCEELPA holds only 31-bit members (CEEPLPKA, EDC*, CEL4CTBL), while the 64-bit C runtime (CELQLIB and its companion CELQ* modules) sits only in CEE.SCEERUN2 on the linklist.

IBM’s Language Environment Programming Guide for 64-bit Virtual Addressing Mode notes that a frequently used AMODE 64 DLL can be installed in dynamic LPA so its reentrant part is shared across address spaces with a single load instead of being loaded and relocated separately in every new address space.

When CELQLIB is only on the linklist, every 64-bit process start (including command substitutions, #! scripts, and shell spawns) pays to load and relocate it again.

Putting CELQ* into dynamic LPA

The eight CELQ* runtime modules in CEE.SCEERUN2 take about 14 MB total in dynamic LPA (CELQLIB itself is about 10 MB).

1. Test it live right now (no IPL required)

From the operator console, SDSF, or opercmd:

SETPROG LPA,ADD,MODNAME=(CELQDCPP,CELQDEST,CELQDMNP,CELQDSNF,CELQIOTD,CELQLIB,CELQMCHK,CELQV004),DSNAME=CEE.SCEERUN2

Verify that all eight loaded:

D PROG,LPA,MODNAME=CELQLIB

You should see CSV551I ... SUCCESSFUL: 8 from SETPROG, and D PROG,LPA will display CELQLIB as resident (D P CELQLIB ...).

2. Re-applying via REXX / SDSF or batch JCL

If you want a scripted way to test or re-apply it through SDSF (ISFSLASH), this is the REXX exec I keep in zash:

/* REXX - put the 64-bit C runtime (CELQ*) in the dynamic LPA */
address SDSF
isfdelay = "10"

cmd.0 = 1
cmd.1 = "SETPROG LPA,ADD,MODNAME=(CELQDCPP,CELQDEST,CELQDMNP,CELQDSNF,CELQIOTD,CELQLIB,CELQMCHK,CELQV004),DSNAME=CEE.SCEERUN2"

address SDSF "ISFSLASH (cmd.) (WAIT)"
if rc <> 0 then do
    say "ISFSLASH failed, RC="rc
    exit rc
end

do i = 1 to isfulog.0
    say isfulog.i
end
exit 0

You can run it from TSO (EXEC 'YOUR.REXX(CELQLPA)' EXEC) or in batch with IKJEFT01:

//CELQLPA  JOB (ACCT),'CELQ TO DYNAMIC LPA',CLASS=A,MSGCLASS=X,REGION=0M
//TSOBATCH EXEC PGM=IKJEFT01,DYNAMNBR=20
//SYSEXEC  DD DISP=SHR,DSN=YOUR.REXX
//SYSTSPRT DD SYSOUT=*
//SYSTSIN  DD *
  EXEC 'YOUR.REXX(CELQLPA)' EXEC
/*

3. Make it survive IPL in PROGxx

Dynamic LPA is rebuilt at every IPL. To make the change permanent, add a single LPA ADD statement to the PROGxx member in your installation PARMLIB where your Language Environment LPA ADD statements live (for example PROGLE alongside your 31-bit CEE.SCEERUN / CEE.SCEERUN2 entries):

LPA ADD DSNAME(CEE.SCEERUN2) MODNAME(CELQDCPP,CELQDEST,CELQDMNP,CELQDSNF,
              CELQIOTD,CELQLIB,CELQMCHK,CELQV004)

Activate it immediately without an IPL using SET PROG=xx (for example SET PROG=LE), and confirm with D PROG,LPA,MODNAME=CELQLIB.

Measured results: before vs. after

Measured on the same z/OS LPAR and compiler (build/zos-tools/spawn, milliseconds per start, wall time / charged child CPU):

Workload 31-bit 64-bit before LPA 64-bit after LPA
Empty main (tiny.c) 1.55 ms / 0.25 ms 5.83 ms (30.45 ms busy) / 1.25 ms 1.58 ms / 0.25 ms
printf (pr.c) 1.54 ms / 0.25 ms 6.06 ms / 1.25 ms 1.58 ms / 0.25 ms
fork() + wait() (0 MB held) 0.10 ms 4.20 ms 0.10 ms
/bin/zsh startup (64-bit shell) N/A 31.42 ms 3.60 ms
32 starts, 8 in flight N/A 27.50 ms 1.60 ms
Two 64-bit children forked together N/A 2 × 28 ms (serialized) 1.6 ms each (overlapping)

After adding CELQ* to dynamic LPA, the 64-bit timings matched 31-bit:

  • A 64-bit fork() with an empty parent dropped from 4.20 ms to 0.10 ms (42× faster), and the extra CPU charge disappeared.
  • /bin/zsh (a 64-bit shell I did not write) dropped from 31.42 ms to 3.60 ms per startup.
  • For zash, this change lets me ship a 64-bit ASCII binary that starts in 1.34 ms (-c :), ahead of IBM’s 31-bit /bin/sh (2.21 ms).

Don’t let STEPLIB undo your LPA work

One catch: under POSIX(ON), the DLL search order is:

  1. z/OS UNIX file system
  2. JPA
  3. TASKLIB
  4. STEPLIB / JOBLIB
  5. LPA
  6. Linklist

STEPLIB is searched before LPA. If your /etc/profile exports STEPLIB=CEE.SCEERUN:CBC.SCCNCMP:CEE.SCEERUN2, every process searches CEE.SCEERUN2 as a STEPLIB ahead of LPA and loses the residency gain.

Set STEPLIB=NONE in /etc/profile. See the companion article, Cleaning Up a z/OS /etc/profile for Speed and Sanity.

Comments

Loading comments…

Leave a comment

Comments are moderated before appearing. Your email is never published.

Questions or feedback?

Open an issue on GitHub or send a note directly via the contact page.