Repository navigation
Speed up calculate_content_widths: fused first-char flags on ShapedCluster + flat per-cluster scan - #48
Closed
nicoburns wants to merge 2 commits into
Closed
Speed up calculate_content_widths: fused first-char flags on ShapedCluster + flat per-cluster scan#48nicoburns wants to merge 2 commits into
nicoburns wants to merge 2 commits into
Conversation
|
I'll fix CI failures and address comments from users with write access that start with 'DevinAI' or '@devin'.
|
…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.
staging-devin-ai-integration
Bot
force-pushed
the
devin/1789646205-content-widths-main
branch
from
September 17, 2026 12:02
1cef3cd to
d23fc54
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.
Rebase of #46 / #32 onto
main(3fdcdca, which includes upstream linebender#790 conditional hanging). Supersedes both. Recovers most of thecalculate_content_widthsregression from linebender#715 on a 250 KB real-text corpus:ClusterDatascan)main(3fdcdca)CPU-pinned, interleaved, n=12 x 3;
widths-resultidentical (min: 1160.2813, max: 17458.617).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::flushfromfirst_character.info(already loaded there). Additive API onShapedCluster:boundary_before(),whitespace(),char_len().ShapedClusterstays 20 bytes. (The commit message mentions the layout use; that lives in commit 2.)Commit 2 — layout (+ engine round-trip test for the flag decode): when the run has no letter/word spacing (the common case),
calculate_content_widthsscansshaped_clustersdirectly instead ofatoms_start():i == 0 || is_grapheme_start()); askip_atomflag skips a Newline atom's continuation clusters exactly like the atom loop'scontinue;if cluster_hangs { += advance } else { = 0 }) — with no gaps this is equivalent toatom_hanging_advance's "hangs entirely / hangs partially from the logical end" rule;whitespace_hangs(first char, style)is checked beforechar_len() == 1, so letters never loadchars_range; multi-char clusters check every character with its own style, asatom_hanging_advancedoes;hangs_conditionallyis set from the cluster's style; the atom loop uses the atom's first-character style, which only differs for mixed-style multi-cluster atoms (the edge case already flagged in Implement CSS's conditional hanging of whitespace linebender/parley#790 review).Runs with spacing keep the existing
atoms_start()loop (it needsAtomforspacing.atom_advance/atom_hanging_advance).A measurement-only variant with no hanging logic at all runs at ~0.60 ms, so the remaining gap to 0.11 is the hanging-whitespace semantics 0.11 didn't have, not the split data model.
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