lumbda/Makefile
russell@unturf.com dd961d2133 lumbda-www: asm-gc static file server for lumbda.com + caddy race
Ships examples/http-static-server.lsp — ~65 lines of portable Scheme
that reads files from a docroot (default ./www) and serves them over
HTTP/1.0 with MIME dispatch, path-traversal rejection, heap-snapshot
per request. Runs in any tier; target deployment is asm-gc for the
27 KB stripped binary + bounded memory backstop.

Required one asm fix first: heap_grow was mmap'ing fixed HEAP_SIZE
chunks, so any single allocation larger than a chunk (notably the
2.67 MB whitepaper PDF read via file->string) loop-looped through
.ha_overflow forever. Now heap_grow rounds required bytes up to
HEAP_SIZE multiples on oversize alloc, so a big request carves its
own big chunk in one go. Small allocs still land in standard-sized
chunks.

Two new benches:

tests/bench-lumbda-www.sh — drive N small + M large requests against
asm-gc, verify PDF round-trip, sample peak RSS. At 1000/100: 331 req/s
small, 120 req/s large (304 MiB/s), peak 15.5 MB.

tests/bench-www-race.sh — adjacent A/B vs caddy v2.5.1 on the same
docroot. Numbers on this laptop, concurrency 8, 2000 small + 200 large:

                         small req/s  PDF req/s  PDF MiB/s  peak RSS    binary
  lumbda-www (asm-gc)     375          137         349       7–16 MB    27 KB
  caddy file-server       358          231         588       38 MB      38 MB

Reading: lumbda edges caddy on small files (less per-request overhead),
caddy wins 1.7x on large files (sendfile zero-copy; we allocate the
whole file into a string and write it with one syscall). Both byte-
identical on the PDF. Memory: lumbda 2.5-5x less at steady state.
Binary size: 1400x smaller (27 KB vs 38 MB).

Feature gap: caddy has HTTPS, HTTP/2, range, middleware, etc. lumbda
has none of that yet — but for the specific job of serving lumbda.com's
six-file docroot it is viable right now.

Makefile adds `bench-lumbda-www` and `bench-www-race` targets.
137 asm no-GC + 137 asm GC tests still pass.
2026-04-19 12:12:59 -04:00

222 lines
7.8 KiB
Makefile
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ═══════════════════════════════════════════════════════════════════
# lumbda — Python + C + Assembly implementations
# ═══════════════════════════════════════════════════════════════════
#
# Implementations:
# Python lumbda.py bytecode VM, full continuations, portal
# C c/lumbda tree-walker + bytecode VM + x86_64 JIT
# Assembly asm/lumbda pure x86_64, no libc, 13KB binary
#
# Test suites:
# make test Python unit/integration (571 tests)
# make c-test C unit/integration + JIT (76 tests) + functional (114)
# make asm-test Assembly unit/integration/functional (75 tests)
# make functional-test Shared .lsp suite in Python + C (114 each)
# make test-all Everything (836 total)
#
# Benchmarks (each generates reproducible numbers referenced in the
# whitepaper; hardware-independent commands, safety envelope built in):
# make bench Python bench.py (tree-walker vs bytecode VM)
# make c-bench C unit-level microbenchmarks
# make bench-3way §6.4: Python vs C vs asm on sum-to/ack
# make bench-portal §7.5: S-exp/JSON/binary portal save+load timings
# make bench-portal-cross §7.2: 3x3 cross-impl portal save×load matrix
# make bench-web §11.3: HTTP benchmark vs busybox + python http.server
# make bench-rpc-chain §11.4: Py → C relay → asm backend chain timing
# make bench-proof §8.6: EML proof — Lean 4 vs Lumbda tiers
# make bench-all run every bench above back to back
# make friction head-to-head timing: Python vs C vs CPython
#
# Other:
# make examples Run examples in Python + C, compare output
# make docs Generate architecture diagrams
# make whitepaper Build PDF whitepaper
# make clean-all Clean everything
all: test
# ─── Python implementation ────────────────────────────────────────
test:
python3 tests.py
test-verbose:
python3 tests.py -v
bench:
python3 bench.py
bench-verbose:
python3 bench.py -v
repl:
python3 lumbda.py
lint:
python3 -m py_compile lumbda.py
python3 -m py_compile tests.py
python3 -m py_compile bench.py
# ─── C implementation ─────────────────────────────────────────────
c-build:
$(MAKE) -C c all
c-test: c-build
$(MAKE) -C c test
@echo "── C functional tests (shared .lsp suite) ──"
./c/lumbda tests/functional.lsp
c-bench: c-build
$(MAKE) -C c bench
c-repl: c-build
./c/lumbda
c-clean:
$(MAKE) -C c clean
# ─── Assembly implementation ──────────────────────────────────────
asm-build:
$(MAKE) -C asm all
asm-test: asm-build
$(MAKE) -C asm test
asm-repl: asm-build
./asm/lumbda
asm-clean:
$(MAKE) -C asm clean
# ─── All implementations ─────────────────────────────────────────
functional-test: c-build
@echo "═══ Shared functional tests (114 tests) ═══"
@echo "── Python ──"
@python3 lumbda.py --fast tests/functional.lsp | tail -3
@echo "── C ──"
@./c/lumbda tests/functional.lsp | tail -3
test-all: test c-test asm-test functional-test
@echo "════════════════════════════════════════════════════"
@echo "All tests passed (Python + C + Assembly + functional)"
# ─── Benchmarks (reproducible; referenced in whitepaper §6§11) ───
bench-3way: c-build asm-build
@bash tests/bench-3way.sh
bench-portal: c-build asm-build
@bash tests/portal-benchmark.sh
bench-portal-cross: c-build asm-build
@bash tests/portal-cross-test.sh
bench-web: c-build asm-build
@bash tests/web-benchmark.sh
bench-rpc-chain: c-build asm-build
@bash tests/rpc-chain-bench.sh
bench-proof: c-build asm-build
@bash tests/bench-proof.sh
bench-hashset: asm-build
@bash tests/bench-hashset.sh
bench-gc: asm-build
@bash tests/bench-gc-memory.sh
bench-gc-arena: asm-build
@bash tests/bench-gc-arena.sh
bench-gc-adaptive: asm-build
@bash tests/bench-gc-adaptive.sh
bench-gc-http: asm-build
@bash tests/bench-gc-http.sh
bench-lumbda-www: asm-build
@bash tests/bench-lumbda-www.sh
bench-www-race: asm-build
@bash tests/bench-www-race.sh
bench-all: bench c-bench bench-3way bench-portal bench-portal-cross bench-web bench-rpc-chain bench-proof
@echo "═══════════════════════════════════════════════════════════"
@echo "All benchmarks complete. Numbers in the whitepaper §6.4,"
@echo "§7.2, §7.5, §11.3, §11.4 are reproducible from these targets."
# ─── Examples ─────────────────────────────────────────────────────
examples: c-build
@echo "═══ fibonacci.lsp ═══"
@echo "--- Python ---" && python3 lumbda.py --fast examples/fibonacci.lsp
@echo "--- C ---" && ./c/lumbda examples/fibonacci.lsp
@echo
@echo "═══ mergesort.lsp ═══"
@echo "--- Python ---" && python3 lumbda.py --fast examples/mergesort.lsp
@echo "--- C ---" && ./c/lumbda examples/mergesort.lsp
@echo
@echo "═══ objects.lsp ═══"
@echo "--- Python ---" && python3 lumbda.py examples/objects.lsp
@echo "--- C ---" && ./c/lumbda examples/objects.lsp
# ─── Friction benchmark ──────────────────────────────────────────
friction: c-build asm-build
bash friction.sh
# ─── Documentation ────────────────────────────────────────────────
DOT_FILES := $(wildcard docs/*.dot)
DOT_PNGS := $(DOT_FILES:.dot=.png)
docs: $(DOT_PNGS)
docs/%.png: docs/%.dot
dot -Tpng $< -o $@
# ─── Whitepaper ───────────────────────────────────────────────────
VENV := whitepaper/.venv
RST := whitepaper/lumbda-whitepaper.rst
PDF := whitepaper/lumbda-whitepaper.pdf
STYLE := whitepaper/whitepaper.style
$(VENV)/bin/rst2pdf:
python3 -m venv $(VENV)
$(VENV)/bin/pip install --upgrade pip
$(VENV)/bin/pip install rst2pdf
whitepaper: $(PDF)
$(PDF): $(RST) $(STYLE) $(VENV)/bin/rst2pdf
cd whitepaper && ../$(<D)/.venv/bin/rst2pdf \
-s whitepaper.style \
--fit-background-mode=scale \
lumbda-whitepaper.rst \
-o lumbda-whitepaper.pdf
@ln -sf lumbda-whitepaper.pdf whitepaper/WHITEPAPER.pdf
@echo "Built: $(PDF)"
# ─── Clean ────────────────────────────────────────────────────────
clean:
rm -rf __pycache__ *.pyc
clean-whitepaper:
rm -rf $(VENV) $(PDF) whitepaper/WHITEPAPER.pdf
clean-docs:
rm -f docs/*.png
clean-all: clean clean-whitepaper clean-docs c-clean asm-clean
.PHONY: all test test-verbose bench bench-verbose repl lint \
c-build c-test c-bench c-repl c-clean \
asm-build asm-test asm-repl asm-clean \
test-all bench-all examples friction functional-test \
bench-3way bench-portal bench-portal-cross bench-web bench-rpc-chain bench-proof \
docs whitepaper clean clean-whitepaper clean-docs clean-all