Skip to content

[experimental] render: a page whose script holds a long run of letters and digits renders in its usual time again - #12533

Merged
josephfarina merged 2 commits into
mainfrom
josephfarina/render-carried-call-linear
Nov 18, 2026
Merged

josephfarina merged 2 commits into
mainfrom
josephfarina/render-carried-call-linear

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

User impact

A page whose script holds a long run of letters and digits, such as a long hexadecimal or identifier-like string, took minutes to render or ran into the time limit. A page with such a 1 MB string took more than 400 seconds, where it took under 2 seconds before. A string broken up by other characters (prose, base64) was not affected.

Problem and solution fit

  1. Why it occurs: the pass that finds the script's reads of images from the embedded source (its carried(sha256, prefix) calls) could start a match at every character of a run of name characters, so a run of n characters took about n² steps.
  2. Why it harms the task: such a page cannot be rendered in practice.
  3. Why that matters: such strings occur in real pages (hashes, identifiers, encoded data).

The match now starts only where a name starts, so each run is read once.

Expected behavior and authority

A render finishes in its usual time whatever text the page holds; the result (which calls are found and rewritten) is unchanged.

Smallest restoration

  • foundation/render/render-page.mjs: the call pattern starts only at the start of a name.
  • A test and a changeset.

Evidence

  • foundation/render/render.test.mjs: a script with a 400,000-character run of name characters is read in under 2 seconds and the call after it is still rewritten; with the earlier pattern this takes about a minute.

  • On the same kind of script: 80,000 characters take 2.3 s before and under 1 ms after; 1 MB takes 4 ms; the matches are the same.

  • On four generated pages that each hold a 1 MB run of letters and digits (relative imports, unusual names, a monorepo layout, and a folder outside any project): before the fix, all four were stopped at 120 seconds with no file; after it, all four render (exit 0), --reverse restores each exactly, and each file is the same size as before the regression. One render takes 1.43 s, against 1.40 s before the regression.

Scope

  • One defect is restored.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • The render suites, run with CI=1 (788 passed, 3 skipped).
  • ESLint; typecheck; pnpm check:knowledge.

… time again

The pattern that finds the script's carried(sha256, prefix) calls could
start a match at every character of a run of name characters, so a page
with a 1 MB string took minutes. It now starts only where a name starts.
@vercel

vercel Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 18, 2026 1:31am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 18, 2026
@astracat-bot

astracat-bot Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 18, 2026, 2:05 AM UTC

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · e05a480

Storybook · Sandbox · built from this PR's head

Package size: @astryxdesign/cli 5.38 MB packed (+59 B); no new dependencies.

Not run on this PR: add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes requested. The fix itself is sound: the carried-image pass now reads each run of letters and digits once and rewrites the same calls. Two small fixes remain:

  • The new test calls performance.now() without importing it, so the required lint check fails with no-undef at packages/cli/foundation/render/render.test.mjs:263 and :265, and the Testing section's ESLint claim does not hold; add import {performance} from 'node:perf_hooks'; as other CLI tests do.
  • The title says a page with any long string was slow, but only a long run of letters and digits was (a 1 MB base64 or prose string already renders quickly on the base), so reword it to match the changeset, for example "render: a page whose script holds a long run of letters and digits renders in its usual time again", and drop "inline images, fonts" from the description's reasons.
Claims and files checked

Review mode: full; reason: no-earlier-review

Claims:

  • Changeset: a page whose script holds a long run of letters and digits renders in its usual time again. Verified: the base pattern takes 96 s on 400,000 characters, the head 3 ms.
  • Changeset: the pass started a match at every character of such a run. Verified: render-page.mjs:749; on the base, time quadruples each time the run doubles.
  • Changeset: a page with a 1 MB string took minutes. Verified at the pattern level: 400,000 characters already take 96 s. Page renders were not rerun.
  • Description: a run of n characters took about n² steps. Verified: 0.24 s, 0.96 s and 3.8 s at 20,000, 40,000 and 80,000 characters.
  • Description: a match now starts only where a name starts, so each run is read once. Verified: render-page.mjs:749.
  • Description: the calls found and rewritten are unchanged. Verified: identical output on every valid call, and the keep-or-rewrite test passes.
  • Description: large strings in real pages (data, inline images, fonts) are affected. False for inline images and fonts: base64 takes 75 ms per 1 MB on the base.
  • Description: the new test reads a 400,000-character run in under 2 seconds and still rewrites the call after it, and the old pattern takes about a minute. Verified: render.test.mjs:257-267 passes, and the base pattern takes 96 s on that input.
  • Description: 80,000 characters take 2.3 s before and under 1 ms after, and 1 MB takes 4 ms. Verified in magnitude on a slower machine: 3.8 s, 1.2 ms and 7.9 ms.
  • Description: four generated 1 MB pages time out before and render after, --reverse restores them exactly, and a render takes 1.43 s against 1.40 s. Not rerun; consistent with the pattern's cost.
  • Description: one defect is restored, with no new public API and no internal context. Verified: no API or command change, and the public text is clean.
  • Description: the render suites pass (788 passed, 3 skipped). Not rerun in full: render.test.mjs passes 20 of 20, and CI cancelled its test jobs on this head because the CI pool was full.
  • Description: ESLint passes. False: no-undef at render.test.mjs:263 and :265.
  • Description: typecheck passes. Verified for the changed source: no error in the render folder, and tests are outside the typecheck project.
  • Description: the knowledge check passes. Verified: CI ran it with warnings only.
  • Title: a page with a long string renders in its usual time again. Broader than the fix (second finding).

Files:

  • .changeset/render-carried-call-linear.md: clear.
  • packages/cli/foundation/render/render-page.mjs: clear.
  • packages/cli/foundation/render/render.test.mjs: the lint finding above.

Automated review (maintainer link)

@josephfarina josephfarina changed the title [experimental] render: a page with a long string renders in its usual time again [experimental] render: a page whose script holds a long run of letters and digits renders in its usual time again Nov 18, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved pending CI: three test-node shards had not finished on this head yet.

Both earlier points are fixed: the test now imports performance from node:perf_hooks, and the title names a long run of letters and digits. The carried-image pass reads each such run once and rewrites the same calls, so a page with a 1 MB run of letters and digits renders in under a second again.

Claims and files checked

Review mode: incremental; reason: none

Changed rules (0): none.

Claims:

  • Changeset: a page whose script holds a long run of letters and digits renders in its usual time again. Verified: a page with a 1 MB run renders in 0.65 s, against 0.63 s before the regression.
  • Changeset: the image-read pass started a match at every character of such a run. Verified: the base pattern takes 0.24 s, 0.95 s and 3.8 s at 20,000, 40,000 and 80,000 characters.
  • Changeset: a page with a 1 MB string took minutes. Verified: 598 s on the base.
  • Title: same claim as the first changeset line. Verified as above.
  • Description: such pages took minutes or hit the time limit; a 1 MB string took more than 400 s, against under 2 s before. Verified: 598 s on the base, 0.63 s before the regression.
  • Description: strings broken up by other characters (prose, base64) were not affected. Verified: 1 MB of base64 takes 42 ms and 1 MB of prose 8 ms with the base pattern.
  • Description: a run of n characters took about n² steps. Verified: time quadruples each time the run doubles.
  • Description: a match now starts only where a name starts, so each run is read once. Verified: the lookbehind in the pattern; 4,000,000 characters take 29 ms.
  • Description: the calls found and rewritten are unchanged. Verified: the same output on the 1 MB page, and on 200,000 generated scripts a difference only where a name follows a digit, which no call in valid script does.
  • Description: the new test reads a 400,000-character run in under 2 s and still rewrites the call after it; the earlier pattern takes about a minute. Verified: the test passes, and the base pattern takes 95 s on its input.
  • Description: 80,000 characters take 2.3 s before and under 1 ms after, 1 MB takes 4 ms, and the matches are the same. Verified in magnitude: 3.8 s, 0.6 ms and 8 ms.
  • Description: four generated 1 MB pages time out before and render after, --reverse restores each exactly, each file keeps its size, and a render takes 1.43 s against 1.40 s. Not rerun, as the pages are not in the pull request; consistent with a probe page at 598 s on the base and 0.65 s on the head.
  • Description: one defect is restored, with no new public API, visual change, default or interaction model, and no internal context. Verified.
  • Description: the render suites pass. Partly verified: the changed test file passes 20 of 20; CI's last node test shards had not finished.
  • Description: ESLint passes. Verified: CI lint passes and the changed files lint clean.
  • Description: typecheck passes. Verified: CI typecheck passes on this head.
  • Description: the knowledge check passes. Verified: it reports the templates and records aligned.

Files:

  • .changeset/render-carried-call-linear.md: clear.
  • packages/cli/foundation/render/render-page.mjs: clear.
  • packages/cli/foundation/render/render.test.mjs: clear; the earlier lint finding is fixed.

Automated review (maintainer link)

@josephfarina
josephfarina merged commit 01b7514 into main Nov 18, 2026
79 checks passed
@github-actions
github-actions Bot deleted the josephfarina/render-carried-call-linear branch November 18, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — e05a480a Deployed Nov 18, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant