Skip to content

core: recover blitz beta.5 memory regressions and pool node allocations - #259

Open
BernardoPe wants to merge 1 commit into
mainfrom
bpereira/blitz-b5-memory
Open

BernardoPe wants to merge 1 commit into
mainfrom
bpereira/blitz-b5-memory

Conversation

@BernardoPe

Copy link
Copy Markdown
Collaborator

The blitz 0.3.0-beta.5 upgrade added 8 bytes to every ElementData and every
TextLayout. This removes both regressions and cuts retained memory and
allocator traffic on large documents.

How

  • Move presentational_hints from ElementData into ElementRare, gated on
    may_have_hints. ElementData drops 64 -> 56 B on wasm32.
  • Gate content_box_subpixel_offset on the writing-mode feature. TextLayout
    drops 52 -> 44 B on wasm32; ListItemLayout and TextInputData shrink too.
  • Compact LayoutData: shared order, [f32; 4] scrollable_overflow, and a
    pooled unrounded layout allocated only when it differs from rounded.
  • Pack single-attribute Attributes into a tagged one-word slot, and pool
    TextLayout, EvictedLayout, EvictedBreak and taffy::CacheInner in
    64 KiB chunks that deallocate when the pool empties.

Testing

bazel test //:check passes 33/33, with JS/Rust lint, format and workspace
checks. kitesurf-core lib tests pass 1,087/1,087, taffy cache tests 21/21,
and the wasm32 build and taffy no_std build compile clean.

Cold single-page release runs, baseline -> this branch:

  • ecma262-raw: peak 95.84 -> 89.98 MiB, 220,798 fewer allocations (-9.2%).
  • htmlstd-raw: peak 184.65 -> 172.28 MiB, 479,858 fewer allocations (-9.4%).

Resolve latency is flat or faster. Not run locally: the E2E, Playwright,
Puppeteer and WPT lanes, and a writing-mode-enabled build.

Risk

  • scrollable_overflow narrows from f64 to f32, about 1e-3 px at 65k px. No
    code compares overflow coordinates for exact equality.
  • Attributes tags a ThinVec pointer in its low bit, which assumes the header
    stays 2-byte aligned. Unit tests and a 400k-operation sanitizer run cover the
    transitions.
  • The three new patch files and MODULE.bazel.lock revert the change cleanly.

Fixes the ElementData (+8 B) and TextLayout (+8 B) size regressions from the
blitz 0.3.0-beta.5 upgrade and reduces retained memory and allocator traffic on
large documents.

- Move presentational_hints from ElementData into ElementRare gated on
  may_have_hints (ElementData 64 -> 56 B on wasm32)
- Gate content_box_subpixel_offset on the writing-mode feature on TextLayout
  (52 -> 44 B on wasm32), ListItemLayout, and TextInputData
- Compact LayoutData (shared order, [f32; 4] scrollable_overflow, lazy pooled
  unrounded layout when it differs from rounded)
- Pool TextLayout, EvictedLayout, EvictedBreak, single-attribute Attributes
  (1-word tagged pointer), and taffy CacheInner in 64 KiB chunks that free
  automatically when live count returns to zero

Cold single-page release benchmarks (d554baf -> patched):
- ecma262-raw: peak 95.84 -> 89.98 MiB (-5.86 MiB), allocs -220,798 (-9.2%)
- htmlstd-raw: peak 184.65 -> 172.28 MiB (-12.37 MiB), allocs -479,858 (-9.4%)

Signed-off-by: bpereira <bpereira@cloudflare.com>
@github-actions github-actions Bot added the vouch:trusted Author is vouched, a collaborator, or a bot. label Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vouch:trusted Author is vouched, a collaborator, or a bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant