Single-pass aser_slot for HTMX path + kernel eval timing + stable hash

Eliminated double-aser for HTMX requests: build OOB wrapper AST
(~shared:layout/oob-sx :content wrapped_ast) and aser_slot in ONE
pass — same pattern as the full-page path. Halves aser_slot calls.

Added kernel-side timing to stderr:
  [aser-slot] eval=3.6s io_flush=0.0s batched=3 result=22235 chars

Results show batch IO works (io_flush=0.0s for 3 highlight calls)
and the bottleneck is pure CEK evaluation time, not IO.

Performance after single-pass fix:
  Home: 0.7s eval (was 2.2s total)
  Reactive: 3.6s eval (was 6.8s total)
  Language: 1.1s eval (was 18.9s total — double-aser eliminated)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-19 17:03:47 +00:00
parent 96e7bbbac1
commit 8707f21ca2
4 changed files with 20 additions and 15 deletions

View File

@@ -203,21 +203,22 @@ async def eval_sx_url(raw_path: str) -> Any:
ocaml_ctx = {"_helper_service": "sx"}
if is_htmx_request():
# HTMX: aser_slot the content, wrap in OOB layout
# HTMX: single-pass — OOB wrapper + content in ONE aser_slot
oob_ast = [
Symbol("~shared:layout/oob-sx"),
Keyword("content"), wrapped_ast,
]
content_sx = SxExpr(await bridge.aser_slot(
serialize(wrapped_ast), ctx=ocaml_ctx))
return sx_response(await oob_page_sx(content=content_sx))
serialize(oob_ast), ctx=ocaml_ctx))
return sx_response(content_sx)
else:
# Full page: build layout+content AST and aser_slot
# in ONE pass — avoids double-aser that breaks when
# re-parsed content contains islands/reactive symbols.
# Full page: single-pass — layout + content in ONE aser_slot
full_ast = [
Symbol("~shared:layout/app-body"),
Keyword("content"), wrapped_ast,
]
full_text = serialize(full_ast)
body_sx = SxExpr(await bridge.aser_slot(
full_text, ctx=ocaml_ctx))
serialize(full_ast), ctx=ocaml_ctx))
tctx = await get_template_context()
return await make_response(
await sx_page(tctx, body_sx), 200)