Skip to content

zcoder.zsh v0.6.0 — Performance and hardening

Choose a tag to compare

@kekePower kekePower released this 24 Aug 14:06
· 10 commits to main since this release

zcoder.zsh v0.6.0

v0.6.0 is a performance and hardening release. The Zsh runtime was profiled
end to end and its hot paths rewritten around native C-speed primitives, with
no change in behavior; parsing became resilient to malformed model output, the
remote token file is now required to be private, and libraries load lazily by
mode.

Highlights

Performance overhaul

Zsh scalar subscripting rescans a string from its start on every access, which
made several per-character loops quadratic. The hot paths now use character
arrays, subscript-pattern searches, and split+join transforms instead:

  • Parsing a typical 120 KB Ollama response dropped from roughly 15 seconds to
    under 30 milliseconds; a 12 KB response from 193 ms to under 8 ms.
  • JSON string encoding of large histories dropped from 205 ms to 12 ms per
    120 KB message, and skipped members are no longer re-serialized.
  • The multiline prompt editor lays out large pasted prompts arithmetically:
    under 1 ms per keystroke where a 6 KB paste previously cost 68 ms.
  • The transcript renderer caches its output: appends render only the new
    message, and scrolling repaints without re-rendering the conversation.
  • Session saves are incremental, writing only new records: about 1 ms per turn
    on a 340-message session instead of 25 ms and growing with history.
  • Request payload assembly joins message arrays at C speed instead of
    re-copying the growing payload per message.

Every rewritten primitive was verified byte-for-byte against the previous
implementation with differential fuzzing across roughly twelve thousand
randomized cases, including multibyte text, control characters, and malformed
input.

Resilient unicode decoding

  • An unpaired UTF-16 surrogate escape in model output previously aborted the
    whole process mid-parse. Each unpairable surrogate now decodes to the
    Unicode replacement character (U+FFFD) and parsing continues.
  • Valid surrogate pairs, all simple escapes, and every error message are
    unchanged, and a containment guard prevents any locale-specific encoding
    failure from terminating the session.

Private remote token files

  • Both --server and --connect now refuse to start unless the token file is
    owned by the invoking user and carries no group or other permission bits
    (chmod 600; a stricter read-only 400 also works).
  • The refusal happens before any socket is opened and names the exact
    chmod 600 fix. The documented umask 077 setup already produces a
    compliant file.

Faster, leaner launch

  • Libraries load once, on demand: the remote transport loads only when a
    remote mode is selected, and the external-delegate harnesses load on the
    first consultation command.
  • zcoder.zsh mcp ... dispatches through a fast path that loads only the
    configuration and protocol libraries.
  • A new make compile target precompiles the libraries to .zwc wordcode,
    roughly halving launch time. Zsh ignores a stale .zwc, so recompiling is
    an optimization, never a correctness requirement; make clean removes the
    compiled files.

Compatibility and verification

  • Zsh 5.8 or newer
  • Ollama with a tool-capable model
  • 472 automated tests passing, including new coverage for surrogate decoding
    and token-file permissions
  • Differential fuzzing of the rewritten JSON tokenizer, encoder, line wrapper,
    and prompt layout against their previous implementations
  • Live remote smoke checks: authenticated /v1/hello, unauthenticated
    rejection, and launch refusal on permissive token files

No configuration, session, or protocol formats changed; existing sessions and
remote setups continue to work unchanged.

For the full documentation, see the documentation index.