Skip to content

improve(ui): stop loading unused CJK tables during boot - #194241

Merged
steipete merged 3 commits into
mainfrom
solid2/w-perf-chat-budget-final-1106
Nov 6, 2026
Merged

steipete merged 3 commits into
mainfrom
solid2/w-perf-chat-budget-final-1106

Conversation

@steipete

@steipete steipete commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Chat and New Session boot retain CJK token-estimation initialization even when their normalization imports do not use it. Main’s New Session boot was over the cap reduced in #194203.

User Impact

Boot downloads 390 B less normalized gzip and no longer allocates an unused 205 KiB character lookup. Token estimates, rendering, requests, and lazy boundaries are unchanged. No configuration or migration is needed.

Why This Change Was Made

Mark the two fixed, private CJK initializers pure so the bundler can delete them for consumers that do not use token estimation. The regex's immediate expression groups its fixed range-to-pattern computation into the same removable initialization; actual estimator consumers retain both initializers. Lower Chat, New Session, and largest-JS caps to measured head plus 64 B. No cap increases.

Related: #194135, #194203.

Evidence

Acceptance: same-machine production builds at base 349fc9649dd and this source head, generated names normalized by the repository checker; reduce bytes without moving code across lazy boundaries. This is unused-code elimination, so there is no timing or visual change to benchmark.

Normalized gzip surface Base B Head B Delta B Cap B
Chat boot JS 1,287,523 1,287,133 -390 1,287,197
New Session boot JS 796,810 796,420 -390 796,484
Initial JS 89,518 89,518 0 unchanged baseline + existing allowance
Largest JS 559,870 559,480 -390 559,544
Total CSS gzip 324,620 324,620 0 324,684
Total CSS raw 1,675,292 1,675,292 0 1,675,356

Request counts unchanged: initial 3 JS/1 CSS, Chat 20/3, New 15/3. Across this lane, Chat is now 2,548 B below the original 1,289,681 B baseline; the three matched cuts total 2,856 B before concurrent main changes.

  • pnpm ui:build on base and head; paired pnpm ui:check-performance --base-dist … --json: pass. Final cap evaluation has zero violations.
  • pnpm tsgo:ui: pass. Existing CJK contract suite: 34/34 pass.
  • Targeted format, type-aware lint, and diff checks; independent isolated review through P2.
  • Production Knip reports the unrelated extensions/deep-research/browser/client.ts file introduced by feat(research): retain authorized browser research state #177231; exact-base c4f2ca1 rerun reproduces the same file (and reports an existing solid-lint eslint install-state dependency). No new ignored files or exports.
  • No runtime test hook or new test scaffolding. Touched production source LOC: 1,014 → 1,016 (+12/−10); tests unchanged.

Full UI CI requested with ci:full. Prior CSS parity and screenshots remain in #194203; this follow-up does not change CSS or rendered output.

Integration: merged main #194171 before the final paired measurement. Its sidebar projection change is already on main and is not part of this PR diff. The earlier c4f2ca1 pair saved 476 B; the final 349fc96 pair saves 390 B because gzip interactions change with the shared chunk. All final caps remain below their values on main.

CI attempt 1: 100 jobs passed; Real Gateway 2/2 failed before assertions when the device-platform fixture could not bind its allocated localhost port (GatewayLockError, EADDRINUSE). Requested one rerun of only job 128040296326 via the supported job API. This is a diagnosed setup collision, not an inherited-test waiver.

Final validation: CI run 42260650608 attempt 2 passed on exact head d436946f6d726b6a86a45759650c3cc7bfb958c7. The one requested infrastructure retry resolved the setup port collision; no code changes or inherited-failure exception were needed.

Mark fixed private initializers as pure so constant-only consumers do not retain their regex and 205 KiB lookup. Preserve token-estimation consumers and lower normalized Chat, New Session, and shared chunk caps to measured head plus 64 bytes. Matched boot gzip drops 476 bytes; existing CJK contracts remain unchanged.
@steipete steipete added the ci:full Keep ordinary native-locale CI selection on the next PR run. label Nov 6, 2026
@clawsweeper

clawsweeper Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T17:21:55.488424Z d436946 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: XS labels Nov 6, 2026
Measure after merging the landed sidebar projection change. The unused CJK initialization cut saves 390 normalized gzip bytes on this combined head. Keep all caps below main while setting Chat, New Session, and largest JS to their measured values plus 64 bytes.
@steipete
steipete enabled auto-merge (squash) November 6, 2026 17:24
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 6, 2026
@clawsweeper

clawsweeper Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR makes unused CJK initializers removable by the bundler and lowers three Control UI JavaScript byte caps.

Example: Loading Chat using the matched production builds reported in this PR.

  • Before: Chat boot JavaScript measures 1,287,523 B normalized gzip.
  • After: Chat boot JavaScript measures 1,287,133 B, saving 390 B.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, useful patch with no actionable findings; supplied evidence establishes reported artifact savings rather than observed browser allocation behavior.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its matched production-build measurements support unused-code elimination, while existing estimator tests support preserved semantics and the downloaded images establish only earlier UI parity.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Chat and New Session boot include initialization for token estimation they do not use.
Reason: The maintainer-authored direction removes measured waste with a minimal change and preserves existing behavior, APIs, and configuration.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR removes unnecessary boot initialization through a focused change, with no introduced correctness or security findings; exact-head CI remains unresolved.

Priority: P3
Reviewed head: d436946f6d726b6a86a45759650c3cc7bfb958c7

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No browser allocation trace for this change is supplied; the inspected screenshots cover earlier presentation work.
Agent review details

How this fits together

Control UI imports shared normalization helpers through a barrel that also exports token estimators; bundling determines which initializers reach browser assets, and the existing performance checker measures those assets.

flowchart LR
  A[Control UI imports] --> B[Normalization barrel]
  B --> C[Production bundler]
  D[CJK estimator initializers] --> C
  C --> E[Browser boot assets]
  E --> F[Existing byte budget checker]
  D --> G[Token estimation callers]
Loading

Technical review

Best possible solution:

Keep the focused pure annotations and lower caps while preserving the existing estimator owner and budgeting semantics.

Do we have a high-confidence way to reproduce the issue?

Source shows unconditional initialization through the shared barrel, and the supplied matched builds report the resulting byte reduction; no target code was executed during this review.

Is this the best way to solve the issue?

The change is the smallest complete fix at the existing owner: the annotations cover entire fixed computations, preserve estimator references, and avoid new loading boundaries or runtime machinery.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8662f3bf78dc.

Provenance checked

  • CJK regex and category lookup initialization keeps the original intent (25155c4: Reduce repeated multilingual scanning while preserving estimates and safety floors.)
  • Control UI JavaScript byte caps keeps the original intent (c4f2ca1: Ratchet measured production byte budgets downward with bounded toolchain headroom.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • coaiMax: Raw commit 54d0fdc adds packages/normalization-core/src/cjk-chars.ts:50 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 54d0fdca7ef7; files: packages/normalization-core/src/cjk-chars.ts)

PR surface

Source +2, Other 0. Total +2 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 9 7 +2
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 3 3 0
Total 2 12 10 +2

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is a bounded boot-size and allocation optimization without an established urgent user-facing failure.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 6, 2026, 12:35 PM ET / 17:35 UTC.

@steipete
steipete merged commit ce4260e into main Nov 6, 2026
313 of 317 checks passed
@steipete
steipete deleted the solid2/w-perf-chat-budget-final-1106 branch November 6, 2026 17:52
@steipete

steipete commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 7, 2026
)

* perf(ui): drop unused CJK initialization from boot

Mark fixed private initializers as pure so constant-only consumers do not retain their regex and 205 KiB lookup. Preserve token-estimation consumers and lower normalized Chat, New Session, and shared chunk caps to measured head plus 64 bytes. Matched boot gzip drops 476 bytes; existing CJK contracts remain unchanged.

* perf(ui): ratchet byte caps on integrated sidebar head

Measure after merging the landed sidebar projection change. The unused CJK initialization cut saves 390 normalized gzip bytes on this combined head. Keep all caps below main while setting Chat, New Session, and largest JS to their measured values plus 64 bytes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:full Keep ordinary native-locale CI selection on the next PR run. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant