sx-http: native SSR + island placeholders — homepage 158ms, 2MB RSS
Switch SSR from SX adapter to native Sx_render.render_to_html. Islands that fail SSR emit <span data-sx-island="name"> placeholders instead of recursing into client-only bodies. Eliminates the <home symbol error cascade that made the homepage render 23s. Performance (warm, single process): Homepage: 131-191ms TTFB (was 202ms on Quart) — faster Geography: 203-229ms TTFB (was 144ms on Quart) — close Reactive: 155-290ms TTFB (was 187ms on Quart) — similar Memory: 2MB RSS (was 570MB on Quart) — 285x reduction Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1484,13 +1484,15 @@ let http_render_page env path =
|
||||
| _ -> serialize_value body_result
|
||||
in
|
||||
let t2 = Unix.gettimeofday () in
|
||||
(* Phase 2: SSR — render to HTML *)
|
||||
(* Phase 2: SSR — render to HTML using native renderer.
|
||||
Native Sx_render handles islands as placeholders when SSR fails,
|
||||
avoiding deep recursion into client-only island bodies. *)
|
||||
let body_html =
|
||||
try
|
||||
let body_exprs = Sx_parser.parse_all body_str in
|
||||
let body_expr = match body_exprs with
|
||||
| [e] -> e | [] -> Nil | _ -> List (Symbol "<>" :: body_exprs) in
|
||||
sx_render_to_html body_expr env
|
||||
Sx_render.render_to_html body_expr env
|
||||
with e ->
|
||||
Printf.eprintf "[http-ssr] failed: %s\n%!" (Printexc.to_string e); ""
|
||||
in
|
||||
|
||||
Reference in New Issue
Block a user