lumbda/examples
russell@unturf.com 01ea93f68f
binary wire mode: 12x faster than host hashlib at 1M inputs
The S-expression wire format was the bottleneck at huge payload sizes
-- 23.8 s end-to-end for 1M x 16 B inputs on the Python tier, while
the actual CUDA kernel finishes the same workload in ~47 ms. The
hex-S-exp parser ate everything between.

New binary wire mode (magic 'BSHK' prefix; payload is the daemon's
binary portal format verbatim) bypasses S-expression parsing entirely.
Worker writes the blob to disk, calls daemon process-bin, reads result,
prepends 'BSHR' magic, replies.

Measured 3090-ai, daemon warm, localhost:

  workload      Py S-exp    Py binary   C S-exp    C binary
  100 x 16 B     3.43 ms     0.74 ms    0.40 ms    0.15 ms
  1k x 16 B     23.24 ms     0.76 ms    2.77 ms    0.22 ms
  10k x 16 B   218.82 ms     1.27 ms    CLIFF      0.88 ms
  100k x 16 B  2,219 ms     10.18 ms    CLIFF     10.35 ms
  1M x 16 B   23,811 ms    159    ms    CLIFF    157    ms

150x speedup at 1M inputs on Python tier. C tier S-exp CLIFFs
between 1k and 10k inputs (reader payload limit); binary mode
bypasses the CLIFF entirely. At 100k+ inputs both tiers converge
since file I/O + CUDA kernel dominates over wire framing.

Host comparison: hashlib.shake_256 over 1M tiny inputs takes ~2 s
on a single Python core. Bend via binary worker = 157 ms = 12x
faster than host. Bend now wins at huge workloads, not just heavy
ones.

Implementation:

  lumbda.py
    * tcp-send/tcp-recv switched to latin-1 (1:1 byte mapping)
      so binary payloads pass through cleanly. UTF-8 was mangling
      bytes with replacement chars.
    * write-binary-file / read-binary-file primitives.

  c/builtins.c
    * write-binary-file / read-binary-file matching Python tier.

  examples/cuda-fanout/wire.lsp
    * wire-send-raw / wire-recv-raw helpers that frame a raw
      payload string without S-expression serialization.

  examples/cuda-fanout/gpu-worker.lsp
    * handle-binary-shake: write portal blob, daemon process-bin,
      read result, wire-send 'BSHR' + bytes.
    * handle-one dispatches on first 4 bytes of payload: 'BSHK'
      goes to binary path, anything else stays S-exp.

  examples/cuda-fanout/bench_tiers.py
    * make_payload_binary builds the BSHK protocol payload.
    * --binary flag in CLI.

  www/index.html
    * full S-exp + binary comparison table.
    * 'bend now beats host hashlib at huge workloads' headline finding.
2026-06-05 09:40:45 -04:00
..
cuda-fanout binary wire mode: 12x faster than host hashlib at 1M inputs 2026-06-05 09:40:45 -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