From abca040a5dbaa31ea9ed87e874b1a13d0168b12a Mon Sep 17 00:00:00 2001 From: giles Date: Sat, 28 Mar 2026 17:09:16 +0000 Subject: [PATCH] sx-http: pre-warm pages on startup for JIT hot-start MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- hosts/ocaml/bin/sx_server.ml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hosts/ocaml/bin/sx_server.ml b/hosts/ocaml/bin/sx_server.ml index 2e1e0799..c780c18f 100644 --- a/hosts/ocaml/bin/sx_server.ml +++ b/hosts/ocaml/bin/sx_server.ml @@ -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