Skip to content

perf: reuse visible word measurements - #483

Merged
jan-kubica merged 2 commits into
mainfrom
perf/reuse-word-measurements
Jul 24, 2026
Merged

perf: reuse visible word measurements#483
jan-kubica merged 2 commits into
mainfrom
perf/reuse-word-measurements

Conversation

@jan-kubica

Copy link
Copy Markdown
Contributor

Summary

  • reuse the visible-word width when deriving the width of ordinary trailing whitespace
  • preserve exact full-string measurement for kerning and literal tabs
  • account for letter spacing and horizontal scaling at the split boundary
  • add focused measurement-count and typography regressions

PR #482 by @arthrod identified redundant text measurement as an optimization direction. This PR takes a smaller dependency-free slice while retaining the existing line-breaking algorithm.

Performance

  • focused eight-word prose case: 17 to 10 Canvas probes (41% fewer)
  • 20-document DOCX sample: 64,854 to 43,769 probes (32.5% fewer), with identical pagination (838 pages)

The sampled end-to-end wall time remained flat/noisy, so this PR claims fewer Canvas measurements rather than a document-load speedup.

Testing

  • bun test src/layout-engine/measure/measureParagraph.test.ts (117 pass)
  • bun --filter @stll/folio-core test (4,386 pass, 2 expected skips)
  • bun --filter @stll/folio-core typecheck
  • targeted oxlint and oxfmt checks

CC on behalf of jan-kubica

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@jan-kubica, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 46 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e552f62a-47c9-432f-aed7-757301ceb77d

📥 Commits

Reviewing files that changed from the base of the PR and between dafe214 and 8098903.

📒 Files selected for processing (3)
  • .changeset/quick-words-measure.md
  • packages/core/src/layout-engine/measure/measureParagraph.test.ts
  • packages/core/src/layout-engine/measure/measureParagraph.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/reuse-word-measurements

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jan-kubica
jan-kubica merged commit 3fdbea2 into main Jul 24, 2026
8 checks passed
@jan-kubica
jan-kubica deleted the perf/reuse-word-measurements branch July 24, 2026 08:43
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant