lumbda/examples
russell@unturf.com 489776baa4 asm: naive stop-the-world mark-sweep GC as a control group
Adds a second asm build (asm/uncommonlisp-gc) behind the GC_NAIVE
assembler flag, providing the benchmark baseline we previously had
no data for. Same binary, same surface, different allocator:

  - 8-byte header per heap block (size << 1 | mark), placed at -8
    from the tagged pointer so existing untag + offset accesses
    stay unchanged.
  - Chunk list tracked in a side array, letting sweep walk every
    mmap'd region by header-chained blocks instead of guessing.
  - Free list rebuilt each sweep, first-fit alloc with split on
    large-leftover (>= 24 bytes).
  - Mark phase enumerates five root classes: %r14 (global env,
    untagged chain), sym_else_val, sym_table entries, every
    sym_hash_bucket chain, and a conservative scan from current
    %rsp to the initial stack_top captured at _start. The stack
    scan runs twice per word — once as a tagged value, once as a
    potential untagged env-node pointer (size-guarded to 24 bytes
    so it can't walk off a wrong-size block).
  - Transitive marking via an explicit 16K-entry mark stack;
    gc_mark_env walks untagged env chains from %r14 and from every
    closure's env field.
  - heap_alloc preserves the non-GC ABI (only %rax clobbered) so
    existing callers like bi_append, which holds state in %rcx
    across make_pair, keep working.
  - Overflow path uses check-then-write bumps and pads the old
    chunk's tail with a single dead block before growing, so sweep
    never walks into uninitialized mmap'd memory.
  - HEAP_SIZE shrinks to 1 MB under GC_NAIVE so the collector
    actually runs on ordinary workloads.
  - Two diagnostic builtins in the GC build: (gc-collect) to force
    a collection, (gc-stats) -> (collections . live-bytes).

Control-group bench (examples/bench-gc-memory.lsp, 2000 iterations
of build-sum-discard over 200-element lists, i5-8350U):

  tier           time_ms   peak_rss   final_rss
  asm no-GC       1097     133.9 MB   133.9 MB   (grows, never shrinks)
  asm naive GC    1431       1.1 MB     1.1 MB   (steady state)

124x less memory at a ~30% throughput cost. That is the number we
were guessing at before. Reproduce: make bench-gc.

Tests: 137 asm (no-GC) + 137 asm (GC) + 189 shared functional pass.
The two asm builds are tested independently via UNCOMMONLISP_BIN in
asm/test.sh; asm/Makefile now builds both and exposes a test-gc
target.
2026-04-18 09:34:51 -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 asm: native hash-set + benchmark — 15-21x over portable 2026-04-18 06:15:21 -04:00
fibonacci.lsp Add peephole optimizer, --help, examples, README update 2026-04-13 16:56:21 -04:00
generator.lsp Add peephole optimizer, --help, examples, README update 2026-04-13 16:56:21 -04:00
http-client-bench.lsp heap-snapshot + native HTTP client + MOAD-0001 cleanup 2026-04-16 20:49:32 -04:00
http-server.lsp heap-snapshot + native HTTP client + MOAD-0001 cleanup 2026-04-16 20:49:32 -04:00
mergesort.lsp Add peephole optimizer, --help, examples, README update 2026-04-13 16:56:21 -04:00
objects.lsp Add peephole optimizer, --help, examples, README update 2026-04-13 16:56:21 -04:00
portal-http-client.lsp portal over HTTP: 9/9 cross-runtime, plus eval-to-global-env fix 2026-04-17 13:41:48 -04:00
portal-http-server.lsp portal over HTTP: 9/9 cross-runtime, plus eval-to-global-env fix 2026-04-17 13:41:48 -04:00
portal-prime.lsp Add portal: serialize and resume VM state across machines 2026-04-13 19:00:11 -04:00
proof-netspace-client.lsp proof netspace: envelope teleport + portable hash-table on vectors 2026-04-17 21:36:26 -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 proof netspace: 2-node spiral demo — independent caches converge 2026-04-18 05:29:23 -04:00
repl-server.lsp S-expressions over sockets — RPC + remote REPL in portable Scheme 2026-04-17 09:00:04 -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 S-expressions over sockets — RPC + remote REPL in portable Scheme 2026-04-17 09:00:04 -04:00
rpc-relay.lsp rpc-chain-bench: Python → C relay → asm, timing end-to-end 2026-04-17 09:18:42 -04:00
rpc-server.lsp S-expressions over sockets — RPC + remote REPL in portable Scheme 2026-04-17 09:00:04 -04:00
spiral-client.lsp proof netspace: 2-node spiral demo — independent caches converge 2026-04-18 05:29:23 -04:00
spiral-demo.sh proof netspace: 2-node spiral demo — independent caches converge 2026-04-18 05:29:23 -04:00