sx-http: pre-warm pages on startup for JIT hot-start

Render 5 key pages during startup to trigger JIT compilation of page
functions, aser, render-to-html, and all component paths. Steady-state
performance after warmup:

  Homepage:  212-280ms (aser=136-173ms, ssr=44-90ms)
  Geography: 282-354ms (aser=215-273ms, ssr=44-61ms)
  Reactive:  356-522ms (aser=306-390ms, ssr=38-109ms)

SSR phase is fast (streaming renderer). Aser is the bottleneck —
response caching eliminates it for static pages.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-28 17:09:16 +00:00
parent 1412648f6e
commit abca040a5d

View File

@@ -1796,6 +1796,16 @@ let http_mode port =
ignore (env_bind env "expand-components?" (NativeFn ("expand-components?", fun _args -> Bool true)));
(* Inject shell statics *)
http_inject_shell_statics env;
(* Pre-warm: render key pages to trigger JIT compilation of page functions,
aser, render-to-html, and shell components. Discards results. *)
let warmup_paths = ["/sx/"; "/sx/(geography)"; "/sx/(geography.(reactive.(examples)))";
"/sx/(applications.(sxtp))"; "/sx/(geography.(cek))"] in
let wt0 = Unix.gettimeofday () in
List.iter (fun path ->
ignore (http_render_page env path)
) warmup_paths;
let wt1 = Unix.gettimeofday () in
Printf.eprintf "[sx-http] Pre-warmed %d pages in %.3fs\n%!" (List.length warmup_paths) (wt1 -. wt0);
(* Write full response to a socket *)
let write_response client response =
let resp_bytes = Bytes.of_string response in