Skip to content

Commit d786bcf

Browse files
ryansolidclaude
andcommitted
docs(perf): Vapor lane §18 — one template clone path priced on the board; keep the importNode special case
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 4ea2f49 commit d786bcf

1 file changed

Lines changed: 76 additions & 0 deletions

File tree

‎documentation/performance-experiments.md‎

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10362,3 +10362,79 @@ a scheduler design question, not a tweak. A Vapor-style text cache would
1036210362
change behaviour. Local only: the branches `perf/write-path-constant`,
1036310363
`perf/insert-text-in-place` and `perf/normalize-split` with its stash, and
1036410364
the fork builds `dist-pw-*`, `dist-ip-*`, `dist-ns-*` and `dist-scan`.
10365+
10366+
### 18 (Vapor lane, follow-up): one template clone path — `importNode` or adopt-once, priced on the board (2026-10-25)
10367+
10368+
`template(html, flag)` clones through `cloneNode(true)` from the node parsed
10369+
into a `<template>`'s inert document, and switches to
10370+
`document.importNode` when the compiler sets flag 1: custom elements, `is`
10371+
attributes, or a lazy-loading `<img>`/`<iframe>`
10372+
(`template_subtree_is_import_node`, `packages/compiler/src/dom/element.rs`).
10373+
`importNode` creates the clone in the document, so a custom element upgrades
10374+
at clone time, before Solid's walk sets its properties. A `cloneNode` copy
10375+
from the inert document upgrades only when it is inserted. The question was
10376+
whether one path could replace the special case, and what that costs on the
10377+
Octane board.
10378+
10379+
**No board fixture emits flag 1.** A scan of every built Solid fixture bundle
10380+
found no flagged template, no `loading=` attribute and no custom-element
10381+
tag. Dropping the flag in favour of plain `cloneNode` changes nothing on the
10382+
board, but it reopens the upgrade-timing problem the flag exists for. The
10383+
measurable choice is a uniform path that is also correct for custom
10384+
elements:
10385+
10386+
- **import** (`perf/template-import`, 3d4f9ffa9): every template clones
10387+
through `document.importNode`.
10388+
- **adopt** (`perf/template-adopt`, d0c7633bb): `create` adopts the parsed
10389+
node into the document once (`document.adoptNode`), then every clone uses
10390+
`cloneNode(true)`. The clone is born in the document, so nothing is adopted
10391+
on insertion.
10392+
10393+
Both pass every web suite that passes on `next` in that worktree. Four
10394+
`UNCOMMITTED_INPUT_OVERWRITTEN` dev tests and one #4240 server test fail
10395+
there on `next` too.
10396+
10397+
**Setup.** `next` @ 4ea2f4986 and both probes, two rounds interleaved per
10398+
round (next, import, adopt), 11 client suites chosen for template mounts.
10399+
Results are in `results-tpl-{next,import,adopt}-r{1,2}-oct25`, the log in
10400+
`.logs/template-clone-2026-10-25.log`. Each figure is Solid's own per-op
10401+
score against `next` from the same round, as a geomean over ops and then
10402+
over rounds. list-clear has no Solid target, which leaves 10 suites.
10403+
10404+
| suite | import | adopt | `next` r2 / r1 |
10405+
| --- | ---: | ---: | ---: |
10406+
| js-framework | +4.7% | +2.6% | −2.8% |
10407+
| todomvc | +7.6% | +6.8% | +0.3% |
10408+
| chat-stream | +11.5% | +9.8% | +10.2% (noise) |
10409+
| svg-dashboard | +0.8% | +0.3% | 0.0% |
10410+
| uibench | +0.5% | +1.4% | −0.2% |
10411+
| spa-navigation | +9.6% | +6.4% | +2.0% |
10412+
| application-composition | −0.8% | −2.5% | +0.8% |
10413+
| scaling-curves | −5.4% | −5.4% | −0.5% |
10414+
| effectful-list | +5.4% | +6.0% | +0.4% |
10415+
| memo-wall | −0.9% | +1.3% | −0.1% |
10416+
| **geomean, 10 suites** | **+3.2%** | **+2.6%** | \|noise\| 1.7% |
10417+
10418+
Ops that moved more than 5% the same way in both rounds, for both probes:
10419+
the creation ops. js-framework `run` +13–14%, `runlots` +16–18%, `add`
10420+
+11%, `replace` +8% (import). spa-navigation `nav_nested`, `nav_deep` and
10421+
`nav_mount` +9–16%. todomvc toggles +24–26%. uibench `render` cases +5–8%.
10422+
uibench's deep-tree `removeAll` is +33–34% on both, which suggests the cost
10423+
does not stop at the clone: nodes born in the document are slower to tear
10424+
down as well. js-framework `select` (−13–14%) and todomvc `clearCompleted`
10425+
(−8%) improved on both probes. Neither clones a template, so they probably
10426+
reflect a different heap shape, not the path itself.
10427+
10428+
**Board impact.** Holding the 15 untouched suites at zero, the change to the
10429+
25-suite board geomean is +1.3% for import and +1.0% for adopt. Without
10430+
chat-stream, whose own round-to-round spread is 10%, it is +0.8% and +0.7%.
10431+
The cost lands on creation ops, 10–17% on the most clone-heavy.
10432+
10433+
**Verdict.** Keep the special case. `cloneNode` from the template's inert
10434+
document, with adoption on insertion, is the fastest path in Chromium. It is
10435+
faster than creating each clone in the document, by `importNode` or from a
10436+
pre-adopted node: adopt-once beats `importNode` by about half a percent and
10437+
still loses to `next`. The flag costs only templates that need it, and none
10438+
of the board's do. Removing it is worth doing only if custom-element upgrade
10439+
timing is dropped as a guarantee, which is a semantics call, not a speed
10440+
call. The probe branches stay local.

0 commit comments

Comments
 (0)