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:
@@ -258,9 +258,10 @@ and render_list_to_html head args env =
|
||||
| Component c when c.c_affinity = "client" -> "" (* skip client-only *)
|
||||
| Component _ -> render_component v args env
|
||||
| Island _i ->
|
||||
(* Islands: SSR via the SX render-to-html from adapter-html.sx.
|
||||
(* Islands: try SSR via the SX render-to-html from adapter-html.sx.
|
||||
It handles deref/signal/computed through the CEK correctly,
|
||||
and renders island bodies with hydration markers. *)
|
||||
and renders island bodies with hydration markers.
|
||||
On failure, emit a placeholder — client hydrates from SX source. *)
|
||||
(try
|
||||
let call_expr = List (Symbol name :: args) in
|
||||
let quoted = List [Symbol "quote"; call_expr] in
|
||||
@@ -269,9 +270,9 @@ and render_list_to_html head args env =
|
||||
(match result with
|
||||
| String s | RawHTML s -> s
|
||||
| _ -> value_to_string result)
|
||||
with e ->
|
||||
Printf.eprintf "[ssr-island] ~%s FAILED: %s\n%s\n%!" _i.i_name (Printexc.to_string e) (Printexc.get_backtrace ());
|
||||
"")
|
||||
with _e ->
|
||||
(* Placeholder — client will hydrate this island *)
|
||||
Printf.sprintf "<span data-sx-island=\"%s\"></span>" _i.i_name)
|
||||
| Macro m ->
|
||||
let expanded = expand_macro m args env in
|
||||
do_render_to_html expanded env
|
||||
|
||||
Reference in New Issue
Block a user