lumbda/examples
russell@unturf.com 58fd787ebf
bend: worker health heartbeat — (health) op + cache + VRAM-ranked pick
Adds a (health) op handler on the worker side & a lazy-refresh
health cache + VRAM-aware selection on the bend client side.

WORKER (gpu-worker.lsp)
  (health) returns (ok (load-avg L) (vram-free-mb V) (uptime-ms U))
  - L from /proc/loadavg first field
  - V from `nvidia-smi --query-gpu=memory.free --format=csv,noheader,nounits`
    (returns 0 when nvidia-smi missing — host w/o NVIDIA GPU)
  - U from current-time-ms; client detects a worker that hung
    & restarted between probes via uptime jump
  Backward-compat: workers without (health) return
  (error (unknown-op health)); client treats that as ok+vram=0.

CLIENT (bend.lsp)
  *worker-health* alist keyed "host:port" → (last-checked-ms status vram-mb)
  Cache TTL on ok = 5 s; cooldown on down = 30 s.
  bend-pick-worker now:
    - filters out workers in down-cooldown
    - sorts healthy peers by free VRAM descending
    - falls back to round-robin if every worker is in cooldown
  bend-dispatch-to-gpu flips workers to down on tcp-connect-fail
    or empty-reply so a transient failure costs at most one call.

Two lumbda quirks caught while building:
  - (eq? 0 #f) → #t in lumbda. worker-probe-health returns 0
    (a number) for the unknown-op fallback, but if we'd checked
    (eq? vram #f) we would have mis-marked the worker down.
    Now uses (number? vram) instead.
  - tcp-connect raises a Python ConnectionRefusedError (NOT a
    LispErr) on dead-host probes. lumbda's `guard` only catches
    LispErr; only with-exception-handler catches Python
    exceptions. Probe now wraps via with-exception-handler so a
    single dead worker never aborts a fleet iteration.

Smoke on Python tier:
  mixed (127.0.0.1:1 dead + 3090-ai live) → cache shows down for
  the dead one (30s cooldown), ok for live (22777 MB free VRAM,
  measured by the worker's nvidia-smi probe).
2026-06-06 09:25:08 -04:00
..
cuda-fanout bend: worker health heartbeat — (health) op + cache + VRAM-ranked pick 2026-06-06 09:25:08 -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