New infra:
- examples/http-server-noarena.lsp: same HTTP server minus the
heap-snapshot/heap-restore arena loop. Isolates whether the GC
build actually holds memory under real traffic, independent
of the portable snapshot pattern.
- tests/bench-gc-http.sh: drives 5,000 concurrent requests per
cell across the full 2x2 matrix {no-GC, GC} x {snapshot, no}.
- Makefile: new `bench-gc-http` target.
Extended benches to exercise both asm binaries:
- tests/bench-hashset.sh now runs against both asm/uncommonlisp
and asm/uncommonlisp-gc, with set +e so a GC-build crash on
one workload doesn't abort the other.
- tests/web-benchmark.sh adds a dedicated asm-gc row (and prints
its stripped binary size) so the HTTP throughput comparison
reports both.
Whitepaper updates:
- §6.6.4 "Validation: HTTP Server Under Sustained Load" — the
4-cell memory matrix. 3/4 cells green; cell 4 (GC + no
snapshot) crashes at first GC trigger — another instance of
the conservative-scan type-confusion class we already fixed
once at the env/string boundary. Logged as a known issue
rather than shipping a partial fix under time pressure.
heap-snapshot + heap-restore remains the recommended pattern
for production asm code; the naive GC is diagnostic + control
group, not a replacement for the arena discipline.
- §6.5 hash-set speedup table slightly softened to ~15-20x (was
15-21x) since run-to-run noise on a shared laptop shifts the
per-phase ratio by a few percent. Ratio is stable to first
order.
- §8.6 narrative references the ~1280x symbolic-vs-brute-force
figure instead of the stale 40x.
- §6 reproducibility list now lists `make bench-gc-http`.
All 137 asm no-GC + 137 asm GC + 189 shared functional tests
still pass.
85 lines
2.7 KiB
Text
85 lines
2.7 KiB
Text
;;; http-server-noarena.lsp — same HTTP server as http-server.lsp
|
|
;;; but with the heap-snapshot / heap-restore arena loop removed.
|
|
;;;
|
|
;;; On asm without GC this leaks per-request allocations forever
|
|
;;; (every request grows %r15). On asm with GC_NAIVE the collector
|
|
;;; reclaims between requests once heap pressure hits.
|
|
;;;
|
|
;;; Used by tests/bench-gc-http.sh to isolate whether GC_NAIVE
|
|
;;; actually holds memory under real load, independent of the
|
|
;;; portable snapshot pattern.
|
|
|
|
(define *port* 8080)
|
|
(define *crlf* "\r\n")
|
|
(define *crlf-crlf* "\r\n\r\n")
|
|
(define *max-requests* 100000)
|
|
|
|
(define (http-response status ctype body)
|
|
(string-append
|
|
"HTTP/1.0 " status *crlf*
|
|
"Content-Type: " ctype *crlf*
|
|
"Content-Length: " (number->string (string-length body)) *crlf*
|
|
"Connection: close" *crlf-crlf*
|
|
body))
|
|
|
|
(define SPACE 32)
|
|
(define (char-at s i) (char->integer (string-ref s i)))
|
|
|
|
(define (first-token s)
|
|
(let ((len (string-length s)))
|
|
(let loop ((i 0))
|
|
(cond
|
|
((= i len) s)
|
|
((= (char-at s i) SPACE) (substring s 0 i))
|
|
(else (loop (+ i 1)))))))
|
|
|
|
(define (second-token s)
|
|
(let ((len (string-length s)))
|
|
(let loop1 ((i 0))
|
|
(cond
|
|
((= i len) "")
|
|
((= (char-at s i) SPACE)
|
|
(let loop2 ((j (+ i 1)))
|
|
(cond
|
|
((= j len) (substring s (+ i 1) len))
|
|
((= (char-at s j) SPACE) (substring s (+ i 1) j))
|
|
(else (loop2 (+ j 1))))))
|
|
(else (loop1 (+ i 1)))))))
|
|
|
|
(define *bench-body*
|
|
(let loop ((s "") (i 0))
|
|
(if (= i 32) s
|
|
(loop (string-append s "0123456789abcdef0123456789abcdef") (+ i 1)))))
|
|
|
|
(define (handle-request req)
|
|
(let ((path (second-token req)))
|
|
(cond
|
|
((string=? path "/")
|
|
(http-response "200 OK" "text/html"
|
|
"<!doctype html><title>uncommonlisp</title><h1>feedback is all you need</h1>"))
|
|
((string=? path "/bench")
|
|
(http-response "200 OK" "text/plain" *bench-body*))
|
|
(else
|
|
(http-response "404 Not Found" "text/plain"
|
|
(string-append "not found: " path "\n"))))))
|
|
|
|
(define server (tcp-listen *port*))
|
|
|
|
(define (server-loop n)
|
|
(if (>= n *max-requests*)
|
|
(begin
|
|
(display "request cap reached, exiting\n")
|
|
(tcp-close server))
|
|
(begin
|
|
(let ((client (tcp-accept server)))
|
|
(let ((req (tcp-recv client 4096)))
|
|
(if (and req (> (string-length req) 0))
|
|
(tcp-send client (handle-request req))
|
|
#f))
|
|
(tcp-close client))
|
|
;; NO heap-restore here — heap grows per request.
|
|
(server-loop (+ n 1)))))
|
|
|
|
(display "noarena http server on :") (display *port*)
|
|
(display " (no heap-snapshot, heap grows per request)") (newline)
|
|
(server-loop 0)
|