Repository navigation
Speed up calculate_content_widths on top of break-spaces (#820): fused cluster flags + flat per-cluster scan - #49
Closed
nicoburns wants to merge 4 commits into
Conversation
…r; use it in calculate_content_widths The width scan no longer touches the character array in its fast path: boundary (2 bits) and whitespace class (3 bits) of a cluster's first character are stored in the free bits of ShapedClusterFlags at shape time. calculate_content_widths walks shaped clusters by index and only slices into characters for multi-cluster/multi-character atoms.
|
I'll fix CI failures and address comments from users with write access that start with 'DevinAI' or '@devin'.
|
staging-devin-ai-integration
Bot
force-pushed
the
devin/1789263416-break-spaces
branch
from
September 20, 2026 12:48
e34ca89 to
e628d13
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LLM Contributions: Written by Devin (Cognition AI) under direction of @nicoburns.
#48 rebased onto the break-spaces branch (#38 / upstream linebender#820, at f76e660), plus one extra commit so the flat scan keeps its speed with linebender#820's
soft_line_breakrule. Stacked on #38; supersedes #48.Corpus benchmark (250 KB real text,
calculate_content_widths, CPU-pinned, interleaved, n=12 x 3;widths-resultidentical):main(3fdcdca)soft_line_breakper atom)Commit 1 — engine:
ShapedClusterFlagshas 5 free bits; they now hold the first character'sBoundary(2 bits) andWhitespace(3 bits, all 8 variants), set inprocess_shaped_clusters::flush. Additive API onShapedCluster:boundary_before(),whitespace(),char_len().ShapedClusterstays 20 bytes. (Message mentions the layout use; that's commit 2.)Commit 2 — layout (+ flag round-trip test): for runs without letter/word spacing,
calculate_content_widthsscansshaped_clustersdirectly instead ofatoms_start(): break/newline checks only on atom-start clusters (i == 0 || is_grapheme_start(), withskip_atomfor a Newline atom's continuation clusters), hanging accumulator updated per cluster (if cluster_hangs { += advance } else { = 0 }, equivalent toatom_hanging_advancewhen there are no gaps),whitespace_hangs(first char, style)checked beforechar_len() == 1so letters never loadchars_range. Runs with spacing keep the atom loop.Commit 3 — break-spaces in the flat scan:
soft_line_break()readscharacters[index-1]andcharacters[index](plus their styles) per atom, which is what made the naive rebase lose most of the gain. The flat scan now evaluates the same rule from the cached flags:boundary_before() == Line && !is_break_space_class(whitespace, style) || is_break_space(characters[start-1]), and only does that (and thecharacters[start-1]load) when some style in the layout usesBreakSpaces(any_break_spaces, computed once per call); otherwise it's justboundary_before() == Line.is_break_spaceis split intois_break_space_class(whitespace, style)+ the existing character-based wrapper.Changelog: None
Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/2564f38c1f574d04ac6e9a57a7284d93
Open in Devin Desktop: https://dioxus.staging.devinenterprise.com/desktop/session/2564f38c1f574d04ac6e9a57a7284d93?variant=devin-insiders