Skip to content

prototyping fused boundary table for branchless loop#137

Draft
cometkim wants to merge 3 commits into
mainfrom
bnd-table
Draft

prototyping fused boundary table for branchless loop#137
cometkim wants to merge 3 commits into
mainfrom
bnd-table

Conversation

@cometkim

@cometkim cometkim commented Jul 9, 2026

Copy link
Copy Markdown
Owner

No description provided.

@changeset-bot

changeset-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d8295ab

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@codspeed-hq

codspeed-hq Bot commented Jul 9, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 12 untouched benchmarks


Comparing bnd-table (d8295ab) with main (a6b246a)

Open in CodSpeed

@cometkim cometkim marked this pull request as draft July 9, 2026 11:50
@pkg-pr-new

pkg-pr-new Bot commented Jul 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/unicode-segmenter@137

commit: d8295ab

@pkg-pr-new

pkg-pr-new Bot commented Jul 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/unicode-segmenter@137

commit: c1beded

@cometkim cometkim changed the title prototyping fused boundary table, ASCII run batching prototyping fused boundary table for branchless loop Jul 9, 2026
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a6b246a) to head (d8295ab).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #137   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           11        11           
  Lines         1005      1007    +2     
=========================================
+ Hits          1005      1007    +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cometkim

cometkim commented Jul 9, 2026

Copy link
Copy Markdown
Owner Author

This grows the pre-allocated memory size but provides no noticeable improvement.

The indirect effect is that it further compacts the main loop, reverting the #135 change, and the countGraphemes() and splitGraphemes() APIs become simple enough that each can have its own loop.

Comment thread src/grapheme-core.js
// so the load never depends on the previous iteration's load; a fully
// fused (state x category) DFA measures 1.4-2x *slower* on V8 for exactly
// that reason.
export const BND = new Uint8Array(256 << 5);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

256 bytes -> 8192 bytes pre-allocated memory, runs almost back to the memory usage allocated in v14.1 (8.5KB) - v14.4 (7.4KB).

It's worth the cost if there are significant advantages in terms of code size or performance.

However, the current library is already compacted very well, and most duplicate code is automatically removed after compression. Smaller code can actually become larger after compression.

I need to check other platforms additionally in terms of performance. Such as Safari and Firefox.

cometkim added a commit that referenced this pull request Jul 9, 2026
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