lumbda/examples
russell@unturf.com 494ae3193c
Python tier: spawn-process-stdio + flush-port; gpu-worker.lsp end-to-end
Two new primitives in the Python tier dispatch table make
gpu-worker.lsp (pure Scheme) replace mock-worker.py:

  (spawn-process-stdio path args) → (stdin-port . stdout-port)
    spawns a long-running subprocess via subprocess.Popen with
    stdin/stdout piped + line-buffered. Returns a Pair the
    caller holds across many request cycles.

  (flush-port port)
    flushes a write port. No-op when port has no flush method.

read-line also extended to accept file-like ports (subprocess pipes)
not just StringInputPort / sys.stdin.

gpu-worker.lsp fixes:
  - run-loop split out as its own tail-recursive function (named-let
    inside cond was harder to debug than non-named explicit recursion)
  - handle-cuda-shake-fanout unwraps (quote ...) wrapping that
    bend.lsp adds when it serializes `'expr` through write-to-string

End-to-end on 3090-ai (lumbda Python tier as both client + worker):

  shell A:  python3 -u lumbda.py /tmp/launch-worker.lsp
            → gpu-worker: ready cuda-shake-fanout ← ./shake256-fanout
            → gpu-worker listening on port 9091

  shell B:  python3 lumbda.py smoke-bend.lsp     # run 3×
            === smoke-bend ===
            1. cost estimator picks local for 3 inputs (cost too small): OK
            2. worker available? #t
            3. bend! (cuda-shake-fanout '("00" "01" "deadbeef") 32):
               ("b8d01df855…" "94da6280b2…" "fa094fa86e…")

  All three runs identical bytes. All three hashes byte-identical to
  hashlib.shake_256 — verified across the full chain:

    lumbda Python → bend macro → wire-send (length-prefixed S-exp)
      → gpu-worker.lsp (pure Scheme) → spawn-process-stdio
      → shake256-fanout --daemon (warm CUDA context on 3090)
      → kernel → output portal → wire-send response → bend returns

  No Python mock anywhere — except the leaf CUDA binary, which is the
  point of the contribution.

Documented in README.md including the python3 -u footnote for
buffering. Once a Scheme-level (flush-port (current-output-port))
is wired into the worker loop, even -u becomes optional.

Per-tier status after this commit:
  Python tier ✓ end-to-end working
  C tier      → still needs spawn-process-stdio + flush-port in
                its primitive dispatch (Scheme files unchanged)
  asm tier    → same, plus raw fork+pipe+execve syscalls for the
                spawn primitive
2026-06-04 19:36:15 -04:00
..
cuda-fanout Python tier: spawn-process-stdio + flush-port; gpu-worker.lsp end-to-end 2026-06-04 19:36:15 -04:00
bench-gc-adaptive.lsp asm-gc: adaptive EMA-driven meta-GC policy + bench + two correctness fixes 2026-04-18 11:33:39 -04:00
bench-gc-arena.lsp asm-gc: meta-GC layer — arena fast path with mark-phase verifier 2026-04-18 10:01:28 -04:00
bench-gc-memory.lsp asm: naive stop-the-world mark-sweep GC as a control group 2026-04-18 09:34:51 -04:00
bench-hashset.lsp rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
fibonacci.lsp rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
generator.lsp rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
http-client-bench.lsp rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
http-server-noarena.lsp rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
http-server.lsp rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
http-static-server-adaptive.lsp lumbda-www: sendfile(2) primitive + adaptive preload — matches caddy throughput at 9x less RSS 2026-04-19 12:41:40 -04:00
http-static-server-cached.lsp lumbda-www cached: in-memory hash-table cache, 1.64x PDF throughput 2026-04-19 12:18:56 -04:00
http-static-server-sendfile.lsp lumbda-www: sendfile(2) primitive + adaptive preload — matches caddy throughput at 9x less RSS 2026-04-19 12:41:40 -04:00
http-static-server.lsp lumbda-www: asm-gc static file server for lumbda.com + caddy race 2026-04-19 12:12:59 -04:00
mergesort.lsp rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
objects.lsp rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
portal-http-client.lsp rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
portal-http-server.lsp rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
portal-prime.lsp rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
proof-netspace-client.lsp rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
proof-netspace-node-a.lsp proof netspace: 2-node spiral demo — independent caches converge 2026-04-18 05:29:23 -04:00
proof-netspace-node-b.lsp proof netspace: 2-node spiral demo — independent caches converge 2026-04-18 05:29:23 -04:00
proof-netspace-server-lib.lsp proof netspace: 2-node spiral demo — independent caches converge 2026-04-18 05:29:23 -04:00
proof-netspace-server.lsp rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
repl-server.lsp rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
rpc-chain-bench.lsp rpc-chain-bench: Python → C relay → asm, timing end-to-end 2026-04-17 09:18:42 -04:00
rpc-client.lsp rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
rpc-relay.lsp rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
rpc-server.lsp rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
spiral-client.lsp rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
spiral-demo.sh rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
ursa-scheme.lsp zoe-favorites-test: cover all four tiers (Python + C + asm + asm-full) 2026-04-24 12:27:51 -04:00
ursa.lisp.txt cl-compat: run Zoë Trout's favorites unchanged (ticket 0004) 2026-04-24 07:02:21 -04:00