Conversation
…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.
Interesting! For me And versus that PR's parent's parent |
|
#855 that landed gives a further nice speed-up on our benches. What exactly is your |
|
My benchmarks are showing something like -8% from #863, then +18% from #864, then -25% from #855 (which for some reason seems to subsume the benefits of this PR). I think it's partly due to inlining decisions. So it may depend on compiler settings (notably |
|
(not necessarily intending to land this) |
LLM Contributions: Generated with Opus 5.5 High
Fixes a linebreaking performance regression from #864 ("Handle line heights changing within atoms").
My LLMs
break_all_lines+alignbenchmark on a ~250KB uniform-style English document went 3.27ms → 3.98ms (+22%).DRAFT because benchmarking is currently showing that #855 gains all the benefits of this change and more
Root Causes
BreakerState::append_atom_to_linestopped inlining intobreak_nextand became an out-of-line call per atomLineBoxMetrics::add_textdid extra work per atom before thelast_textearly-return: an eageratom.characters()slice (with bounds check) and adata.runs[run_idx].has_mixed_style_atomsload.Fixes
atom.char_range()and only sliceShapedText::characters()on the slow path.has_mixed_style_atomsinto(item_idx, style_index).add_text_boxessets it to theNO_LAST_TEXTsentinel after adding an atom of a run with mixed-style atoms, so such runs never hit the early return. The fast path check becomes justlast_text == (item_idx, style_index)again.Benchmarked "break" phase:
8af7c033.27–3.33ms,main3.98–4.04msChangelog: None