perf: bound regex literal context checks #43
main fromtaren/highlight-html-output·merged by tannerlinsley Bound the source suffix inspected when deciding whether a slash starts a regex literal. The longest keyword is instanceof, so the final 11 UTF-16 units preserve the keyword and its preceding word boundary. Whitespace trimming and native regex boundary rules stay unchanged.
On repeated complete highlighting of division-heavy JavaScript, Bun 1.3.14 takes about 85% less time at 8KB and 96% less at 32KB. Node 24 shows no consistent change on these inputs, and the 334 documentation fixtures stay near baseline on both runtimes. The larger Bun scaling run was stopped before completion, so those results are not claimed.
Validation: 363 tests; 1,310,720 UTF-16 boundary predicate checks; 17,498 completed-result compatibility checks; 30,670 JS/TS/JSX/TSX semantic fuzz cases; all existing bundle-size and runtime budgets; typecheck, build, docs, skills, package and packed-package checks. Packed package and compatibility pass Node 18, 20, 22, 24 and 26. Two reversed allocation pairs differ by less than 0.4%, and nine fresh retained-heap pairs differ by 8 bytes in their medians. Includes a patch changeset and long-prefix keyword-boundary regression coverage.
Final tradeoff check: on the targeted 32KB division-heavy input, three alternating V8 allocation pairs at a 4096-byte sampling interval show about 3.5% more temporary allocation, consistent with creating short suffix strings. Documentation allocation stays within 0.4% and retained heap is unchanged. This is accepted for the large Bun throughput improvement; no allocation reduction is claimed. Fifteen fresh startup pairs show Node import plus first result near 4.56ms for both versions, and Bun about 44.3ms versus 13.8ms. Three fresh first-result scaling pairs at 128KB and 512KB preserve exact complete output, with Bun medians roughly 477ms versus 7ms and 7.7s versus 21ms. These larger probes measure first work, not steady-state throughput. Independent fuller C integration also passes all local gates without changes to its separate features or budgets.
- 1
Warning
Review limit reached#
You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.
Next included review available in 8 minutes.
View limit details
-
Limit details: You’ve used the included review currently available.
Review configuration:
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
7b921b69-6c6c-4f0b-b241-fee3e2c63f2a
Commits-
Reviewing files that changed from the base of the PR and between f3c722b838b4f606950607881378d9120700869e and 5e4623004375286e67ba137aa8dd7d54c999a8db.
Files selected for processing: 3-
.changeset/bounded-regex-context.mdsrc/internal/script.tstest/regressions.test.ts
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
-
tannerlinsley merged thisa52b8f6
tannerlinsley closed this
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: 5e4623004375286e67ba137aa8dd7d54c999a8db
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR