Skip to content

Box the per-node transform to shrink ElementData - #796

Open
nicoburns wants to merge 3 commits into
mainfrom
devin/1787687735-box-node-transform
Open

Box the per-node transform to shrink ElementData#796
nicoburns wants to merge 3 commits into
mainfrom
devin/1787687735-box-node-transform

Conversation

@nicoburns

@nicoburns nicoburns commented Aug 25, 2026

Copy link
Copy Markdown
Member

Summary

ElementData/DocumentData::transform becomes Option<Box<Affine>> instead of Option<Affine>. Affine is [f64; 6] (48 bytes) with no niche, so the inline Option<Affine> cost 56 bytes on every element even though the vast majority of elements have no CSS transform; boxed it costs 8 bytes (pointer niche), with a heap allocation only for the rare transformed nodes.

Measured with a size_of probe: ElementData drops 1472 → 1424 bytes on main (heap profiling of the Barack Obama Wikipedia page showed ~22.8k elements at the 1536-byte malloc size class dominating the Document heap). Note the standalone win is struct-size only — 1424 still rounds to the same 1536-byte malloc class; it compounds with #794 (which removes the 488-byte owned taffy::Style) and any future Cache shrinking.

Callers adjusted for the extra indirection:

// resolve.rs / node.rs hit-testing
if let Some(t) = node.transform().as_deref() { transform *= *t }
// blitz-paint render.rs
node.transform().as_deref().copied().unwrap_or_default()

Node::set_transform still computes and returns Option<Affine> by value; only the stored field is boxed (transform.map(Box::new)).

Testing

cargo clippy --workspace --all-targets and cargo fmt --all --check pass (one pre-existing clone_on_copy warning in examples/custom_widget.rs unrelated to this change).

Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/9cffd370ef03474e88a93f5335b19b65
Open in Devin Desktop: https://dioxus.staging.devinenterprise.com/desktop/session/9cffd370ef03474e88a93f5335b19b65?variant=devin-insiders
Requested by: @nicoburns

WPT results

No changes in test results compared to main.

Generated by the WPT workflow.

@staging-devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring
@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1787687735-box-node-transform branch from df577fd to c0b405a Compare August 26, 2026 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant