Repository navigation
Commit a732d2b
perf(web): ssrElement joins plain children in place and walks uniform sources without resolved lists
Profiled yak's element-dense SSR cases (dyn-translate, dyn-fair,
dyn-inline) with ssrElement's array-sources form against the library's
hand-written writer: the element path cost about 3.3x the writer per
element, with everything else equal. Two structural causes.
The exit. Every element ran resolveSSRNode(children, undefined, true),
which allocates a fresh { t: [""], h: [], p: [] } result — an object and
three arrays — to append one string to, then ssr([open, close], result)
with a template array and the full hole loop to join it back. The content
most elements end up with is one string (a text child, escaped above or
by the compiler), a number, nothing, or one finished node; those now join
the open and close tags in place. Arrays and pending nodes still take the
resolver — they need it for separators and holes. The ssrTextTail marker
state is not touched: the parent resets it on this element's finished
node either way. Output is byte-identical on all fifteen yak cases and
the server suite.
The array form. sources/kinds lists were built per element even when
every entry was a plain object, the normal case, and an omit over a merge
allocated a fill(SOURCE_OMIT) list. kinds is now the per-entry array or,
when every entry is of one kind, that kind itself, so the array handed in
(or the view's entries) is walked as is. pushEntry classifies a plain
object with one `$PROXY in` check instead of two.
Same-process round-robin against next on yak's SSR lanes: dyn-translate
+21%, dyn-fair +15%, dyn-inline +16% (1.76x -> 1.46x of the writer),
multifile-composition +3%, tabs +6%; sampled allocation on dyn-translate
2959 -> 2161 bytes per instance.
Co-authored-by: Claude via Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>1 parent 37ea885 commit a732d2b
3 files changed
Lines changed: 85 additions & 7 deletions
File tree
- .changeset
- packages/web
- src
- test/server
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3889 | 3889 | | |
3890 | 3890 | | |
3891 | 3891 | | |
| 3892 | + | |
| 3893 | + | |
| 3894 | + | |
| 3895 | + | |
| 3896 | + | |
| 3897 | + | |
3892 | 3898 | | |
3893 | 3899 | | |
3894 | 3900 | | |
| |||
3899 | 3905 | | |
3900 | 3906 | | |
3901 | 3907 | | |
3902 | | - | |
| 3908 | + | |
3903 | 3909 | | |
3904 | 3910 | | |
3905 | 3911 | | |
| |||
3931 | 3937 | | |
3932 | 3938 | | |
3933 | 3939 | | |
| 3940 | + | |
| 3941 | + | |
| 3942 | + | |
| 3943 | + | |
3934 | 3944 | | |
3935 | 3945 | | |
3936 | 3946 | | |
3937 | | - | |
3938 | | - | |
3939 | | - | |
| 3947 | + | |
| 3948 | + | |
| 3949 | + | |
| 3950 | + | |
| 3951 | + | |
| 3952 | + | |
| 3953 | + | |
| 3954 | + | |
| 3955 | + | |
| 3956 | + | |
| 3957 | + | |
| 3958 | + | |
| 3959 | + | |
3940 | 3960 | | |
3941 | 3961 | | |
3942 | 3962 | | |
| |||
3953 | 3973 | | |
3954 | 3974 | | |
3955 | 3975 | | |
3956 | | - | |
| 3976 | + | |
3957 | 3977 | | |
3958 | 3978 | | |
3959 | 3979 | | |
| |||
3982 | 4002 | | |
3983 | 4003 | | |
3984 | 4004 | | |
3985 | | - | |
| 4005 | + | |
| 4006 | + | |
3986 | 4007 | | |
3987 | 4008 | | |
3988 | 4009 | | |
3989 | 4010 | | |
3990 | 4011 | | |
3991 | | - | |
| 4012 | + | |
3992 | 4013 | | |
3993 | 4014 | | |
3994 | 4015 | | |
| |||
4071 | 4092 | | |
4072 | 4093 | | |
4073 | 4094 | | |
| 4095 | + | |
| 4096 | + | |
| 4097 | + | |
| 4098 | + | |
| 4099 | + | |
| 4100 | + | |
| 4101 | + | |
| 4102 | + | |
| 4103 | + | |
| 4104 | + | |
| 4105 | + | |
| 4106 | + | |
| 4107 | + | |
| 4108 | + | |
| 4109 | + | |
| 4110 | + | |
4074 | 4111 | | |
4075 | 4112 | | |
4076 | 4113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
315 | 346 | | |
316 | 347 | | |
317 | 348 | | |
| |||
0 commit comments