Skip to content

Keep the line breaker's per-atom fast path free of mixed-style atom handling - #82

Open
nicoburns wants to merge 1 commit into
mainfrom
devin/1790906099-fix-864-break
Open

nicoburns wants to merge 1 commit into
mainfrom
devin/1790906099-fix-864-break

Conversation

@nicoburns

Copy link
Copy Markdown
Member

LLM Contributions: Investigation, implementation, tests and this description (Devin).

Fixes a break-phase regression from linebender#864 ("Handle line heights changing within atoms"): break_all_lines+align on a ~250KB uniform-style English document went 3.27ms → 3.98ms (+22%, -align-all-functions=6 builds).

Cause

  • BreakerState::append_atom_to_line stopped inlining into break_next and became an out-of-line call per atom (break_remaining shrank 0x12d8 → 0xcf8 bytes).
  • LineBoxMetrics::add_text did extra work per atom before the last_text early-return: an eager atom.characters() slice (its bounds check can't be sunk into the cold branch) and a data.runs[run_idx].has_mixed_style_atoms load.

Fix

  • Fold the flag into last_text: add_text_boxes sets it to NO_LAST_TEXT after adding an atom of a run with mixed-style atoms, so such runs never hit the early return. The fast path is again just last_text == (item_idx, style_index).
  • Pass the atom's characters as atom.char_range() and only slice ShapedText::characters() on the slow path.

Break phase (min ms, 4 interleaved passes): 8af7c03 3.27–3.33, main 3.98–4.04, this PR 3.26–3.31 (one 3.46 outlier), identical layout output.

Adds line_height_change_inside_ligature_after_same_style_atom: a mixed-style ffi ligature preceded by an atom of the same run and first style still contributes the larger line height (fails without the last_text reset). No snapshot changes.

Note: the branch is based on upstream linebender/parley main (244351e), so it also carries linebender#867 and linebender#874, which this fork's main doesn't have yet.

Changelog: None

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

…andling

linebender#864 made append_atom_to_line no longer inline into break_next (it
became an out-of-line call per atom), and added work to the fast path of
LineBoxMetrics::add_text on every atom: an eager atom.characters()
slice (with bounds check) and a data.runs[run_idx].has_mixed_style_atoms
load.

Instead, fold the flag into last_text: add_text_boxes resets last_text
to a sentinel after adding an atom of a run with mixed-style atoms, so
such runs never take the early return. The atom's characters are passed
as a char range and only sliced on the slow path.

Add a test where a mixed-style ligature follows an atom of the same run
and first style.
@staging-devin-ai-integration

Copy link
Copy Markdown

I'll fix CI failures and address comments from users with write access that start with 'Devin'.

  • Disable automatic comment, CI, and merge conflict monitoring

@nicoburns
nicoburns changed the base branch from main to v0.11.x October 2, 2026 01:58
@nicoburns
nicoburns changed the base branch from v0.11.x to main October 2, 2026 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant