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