Repository navigation
perf(Text): a truncation measurement that finds the same result sets no state - #11911
Conversation
…no state useTruncation set isTruncated and fullText on every measurement, even when the values were unchanged, so a list that mounts many texts dispatched many updates that changed nothing. Its setters now skip the dispatch when the value equals the one last set. The hook returns the same values at the same times.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec ecb513f |
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| lab/TabBarMoreList | 102.0 kB (+68 B) · 1.8 kB CSS (0) | — | — · — · — |
| Timer | 13.1 kB (+67 B) · 6.1 kB CSS (0) | — | — · — · — |
| Selector | 112.8 kB (+65 B) · 18.6 kB CSS (0) | — | — · — · — |
99 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| Field | 59.5 kB (+64 B) · 7.3 kB CSS (0) | — | — · — · — |
| lab/Schedule | 114.7 kB (+62 B) · 3.9 kB CSS (0) | — | — · — · — |
| ComplexSelector | 77.6 kB (+60 B) · 12.6 kB CSS (0) | — | — · — · — |
| TextInput | 72.8 kB (+60 B) · 12.0 kB CSS (0) | — | — · — · — |
| Markdown | 202.7 kB (+59 B) · 21.9 kB CSS (0) | — | — · — · — |
| Switch | 109.0 kB (+57 B) · 10.0 kB CSS (0) | — | — · — · — |
| Calendar | 76.1 kB (+54 B) · 11.4 kB CSS (0) | — | — · — · — |
| InputGroup | 61.1 kB (+54 B) · 7.9 kB CSS (0) | — | — · — · — |
| Pagination | 123.8 kB (+54 B) · 19.0 kB CSS (0) | — | — · — · — |
| lab/SelectableCardGroup | 68.8 kB (+54 B) · 162 B CSS (0) | — | — · — · — |
| ChatLayout | 88.3 kB (+53 B) · 11.3 kB CSS (0) | — | — · — · — |
| MultiSelector | 101.5 kB (+53 B) · 17.7 kB CSS (0) | — | — · — · — |
| Slider | 114.5 kB (+53 B) · 8.9 kB CSS (0) | — | — · — · — |
| RadioListItem | 76.1 kB (+52 B) · 10.7 kB CSS (0) | — | — · — · — |
| ToggleButton | 92.1 kB (+52 B) · 10.9 kB CSS (0) | — | — · — · — |
| AlertDialog | 128.7 kB (+51 B) · 15.4 kB CSS (0) | — | — · — · — |
| CheckboxList | 73.2 kB (+51 B) · 7.8 kB CSS (0) | — | — · — · — |
| richtext/RichTextView | 282.2 kB (+51 B) · 2.3 kB CSS (0) | — | — · — · — |
| RadioList | 60.8 kB (+50 B) · 7.3 kB CSS (0) | — | — · — · — |
| Text · Storybook | 11.0 kB (+50 B) · 5.5 kB CSS (0) | 753 (+13) | ✓ · ✓ · — |
| CommandPaletteInput | 33.0 kB (+49 B) · 7.6 kB CSS (0) | — | — · — · — |
| FileInput | 74.2 kB (+49 B) · 11.7 kB CSS (0) | — | — · — · — |
| CheckboxListItem | 79.9 kB (+48 B) · 12.0 kB CSS (0) | — | — · — · — |
| DateRangeInput | 99.3 kB (+48 B) · 13.3 kB CSS (0) | — | — · — · — |
| DropdownMenu | 107.4 kB (+48 B) · 18.8 kB CSS (0) | — | — · — · — |
| DropdownMenuSubMenu | 78.5 kB (+48 B) · 10.4 kB CSS (0) | — | — · — · — |
| ListItem | 79.1 kB (+48 B) · 12.0 kB CSS (0) | — | — · — · — |
| MobileNav | 76.3 kB (+48 B) · 11.4 kB CSS (0) | — | — · — · — |
| SideNavCollapseButton | 65.9 kB (+48 B) · 10.8 kB CSS (0) | — | — · — · — |
| TextArea | 66.9 kB (+48 B) · 9.4 kB CSS (0) | — | — · — · — |
| lab/LineClamp | 13.5 kB (+48 B) · 168 B CSS (0) | — | — · — · — |
| ChatToolCalls | 31.6 kB (+47 B) · 8.4 kB CSS (0) | — | — · — · — |
| MoreMenu | 107.6 kB (+47 B) · 18.8 kB CSS (0) | — | — · — · — |
| Spinner | 24.0 kB (+47 B) · 6.3 kB CSS (0) | — | — · — · — |
| Table | 120.2 kB (+47 B) · 19.6 kB CSS (0) | — | — · — · — |
| Tokenizer | 104.3 kB (+47 B) · 20.3 kB CSS (0) | — | — · — · — |
| lab/EmojiPicker | 92.5 kB (+47 B) · 751 B CSS (0) | — | — · — · — |
| richtext/RichTextEditorToolbar | 299.6 kB (+47 B) · 454 B CSS (0) | — | — · — · — |
| CheckboxInput | 69.0 kB (+46 B) · 10.1 kB CSS (0) | — | — · — · — |
| AppShell | 97.6 kB (+45 B) · 14.3 kB CSS (0) | — | — · — · — |
| DialogHeader | 67.9 kB (+45 B) · 12.3 kB CSS (0) | — | — · — · — |
| lab/DialogHeroHeader | 88.6 kB (+45 B) · 372 B CSS (0) | — | — · — · — |
| ChatMessageList | 27.4 kB (+44 B) · 7.1 kB CSS (0) | — | — · — · — |
| DateTimeInput | 223.5 kB (+44 B) · 19.7 kB CSS (0) | — | — · — · — |
| DrawerHeader | 68.0 kB (+44 B) · 13.7 kB CSS (0) | — | — · — · — |
| NumberInput | 77.6 kB (+44 B) · 12.2 kB CSS (0) | — | — · — · — |
| Popover | 98.6 kB (+44 B) · 15.1 kB CSS (0) | — | — · — · — |
| SideNav | 121.2 kB (+44 B) · 12.2 kB CSS (0) | — | — · — · — |
| TopNav | 78.0 kB (+44 B) · 11.7 kB CSS (0) | — | — · — · — |
| CodeBlock | 80.1 kB (+43 B) · 12.1 kB CSS (0) | — | — · — · — |
| SideNavItem | 77.0 kB (+42 B) · 11.9 kB CSS (0) | — | — · — · — |
| TableCell | 103.3 kB (+42 B) · 19.1 kB CSS (0) | — | — · — · — |
| TableHeaderCell | 103.0 kB (+42 B) · 18.9 kB CSS (0) | — | — · — · — |
| TabMenu | 78.9 kB (+42 B) · 11.9 kB CSS (0) | — | — · — · — |
| ContextMenu | 102.1 kB (+41 B) · 18.7 kB CSS (0) | — | — · — · — |
| DateInput | 200.0 kB (+41 B) · 17.9 kB CSS (0) | — | — · — · — |
| Link | 56.4 kB (+41 B) · 7.1 kB CSS (0) | — | — · — · — |
| PowerSearch | 306.8 kB (+41 B) · 25.5 kB CSS (0) | — | — · — · — |
| Timestamp | 27.0 kB (+41 B) · 11.0 kB CSS (0) | — | — · — · — |
| lab/Comments | 369.8 kB (+41 B) · 2.5 kB CSS (0) | — | — · — · — |
| charts/ChartLegend | 40.2 kB (+40 B) · 224 B CSS (0) | — | — · — · — |
| Carousel | 74.7 kB (+40 B) · 11.7 kB CSS (0) | — | — · — · — |
| lab/ChatEmojiPicker | 113.6 kB (+40 B) · 773 B CSS (0) | — | — · — · — |
| lab/CommentComposer | 173.6 kB (+40 B) · 1.9 kB CSS (0) | — | — · — · — |
| lab/DiffViewer | 93.2 kB (+40 B) · 2.1 kB CSS (0) | — | — · — · — |
| ChatLayoutScrollButton | 65.6 kB (+39 B) · 11.0 kB CSS (0) | — | — · — · — |
| CommandPalette | 77.8 kB (+39 B) · 12.7 kB CSS (0) | — | — · — · — |
| SideNavHeading | 82.5 kB (+39 B) · 12.1 kB CSS (0) | — | — · — · — |
| Toast | 103.6 kB (+39 B) · 11.1 kB CSS (0) | — | — · — · — |
| lab/ListInput | 93.6 kB (+39 B) · 922 B CSS (0) | — | — · — · — |
| TopNavMegaMenu | 76.1 kB (+38 B) · 12.6 kB CSS (0) | — | — · — · — |
| lab/ChatReactionBar | 114.8 kB (+38 B) · 1.1 kB CSS (0) | — | — · — · — |
| lab/CommentThread | 362.9 kB (+38 B) · 2.4 kB CSS (0) | — | — · — · — |
| lab/TourStep | 93.2 kB (+38 B) · 691 B CSS (0) | — | — · — · — |
| richtext/RichTextEditor | 305.6 kB (+38 B) · 2.6 kB CSS (0) | — | — · — · — |
| Stepper | 66.7 kB (+37 B) · 10.9 kB CSS (0) | — | — · — · — |
| TimeInput | 174.8 kB (+37 B) · 16.9 kB CSS (0) | — | — · — · — |
| TopNavMenu | 81.6 kB (+37 B) · 12.0 kB CSS (0) | — | — · — · — |
| ChatDictationButton | 65.6 kB (+36 B) · 10.8 kB CSS (0) | — | — · — · — |
| ChatSendButton | 65.4 kB (+36 B) · 10.8 kB CSS (0) | — | — · — · — |
| Heading | 11.6 kB (+36 B) · 5.5 kB CSS (0) | — | — · — · — |
| Banner | 67.0 kB (+35 B) · 11.3 kB CSS (0) | — | — · — · — |
| ChatComposer | 84.6 kB (+35 B) · 12.9 kB CSS (0) | — | — · — · — |
| Thumbnail | 69.4 kB (+35 B) · 12.3 kB CSS (0) | — | — · — · — |
| IconButton | 65.0 kB (+34 B) · 10.8 kB CSS (0) | — | — · — · — |
| Typeahead | 87.9 kB (+34 B) · 13.5 kB CSS (0) | — | — · — · — |
| TopNavHeading | 82.1 kB (+33 B) · 12.0 kB CSS (0) | — | — · — · — |
| Lightbox | 145.9 kB (+32 B) · 11.9 kB CSS (0) | — | — · — · — |
| TableSelectionToolbar | 75.3 kB (+32 B) · 14.0 kB CSS (0) | — | — · — · — |
| Button | 65.0 kB (+31 B) · 10.8 kB CSS (0) | — | — · — · — |
| MobileNavToggle | 65.3 kB (+31 B) · 10.8 kB CSS (0) | — | — · — · — |
| lab/TransferListSelector | 121.1 kB (+31 B) · 1.4 kB CSS (0) | — | — · — · — |
| BaseTypeahead | 78.4 kB (+30 B) · 11.7 kB CSS (0) | — | — · — · — |
| ChatComposerInput | 82.2 kB (+26 B) · 12.1 kB CSS (0) | — | — · — · — |
| ChatComposerTokenElement | 82.2 kB (+26 B) · 12.1 kB CSS (0) | — | — · — · — |
| lab/TransferList | 112.2 kB (+26 B) · 1.2 kB CSS (0) | — | — · — · — |
| BreadcrumbItem | 96.9 kB (+25 B) · 13.3 kB CSS (0) | — | — · — · — |
| charts/ChartTooltip | 215.0 kB (+17 B) · 451 B CSS (0) | — | — · — · — |
| charts/Chart | 237.9 kB (+15 B) · 516 B CSS (0) | — | — · — · — |
Package size: @astryxdesign/core 7.61 MB packed (+365 B); no new dependencies.
Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Request changes — one reporting gap; the code itself is clean, and the hook's returned values match main at every step this review probed.
packages/core/src/Text/useTruncation.tsis imported by the Text, Heading and Lightbox folders and by Lab's LineClamp, so it is a shared module, and this head grows it (its built output rises from 1,978 to 2,133 B gzip);architecture:component-import-boundariesINV10 asks a pull request that grows a shared module to report the first-load gzip delta on the four reference pages, and the description reports none. Measured here withpnpm size:pagesover both trees' Core builds: docs +15 B, form +14 B, menu +28 B, table +9 B gzip, every page well inside INV10's 0.3 KB allowance — pasting those four numbers into the Evidence section clears this.
Two non-blocking notes: the release note opens [fix] while the change is a performance change with identical returned values, so [perf], which the repository already uses for this kind of note, would file it under Performance in the changelog; and packages/core/src/hooks/useScrollableArea.ts already holds a private setIfChanged with the same body, so the two copies can drift. Required CI has not run on this head yet, so the merge guard still needs it green.
Claims and files checked
Review mode: full; reason: no-earlier-review
Claims:
- Pages that mount many truncating texts are affected, such as a wide Table whose default cell renders clamped Text — verified (
packages/core/src/Table/BaseTable.tsx:277). - Before the change every measurement set both values even when unchanged — verified (the base hook calls both setters unconditionally).
- About 119 such updates per Table column-range step, from a real-Chrome stack probe — unverified: that harness is outside this pull request and this review has no real browser; the description says the results land before the pull request leaves draft.
- After the change a measurement that finds the same values dispatches nothing — verified (a re-measurement of the same text drops from 2 dispatches to 0).
- The hook's public return is identical, at the same times — verified (base-against-head probe over mount, growth past the box, expand, collapse, element swap and a short text, in StrictMode and outside it).
- The hook keeps the last values in a ref and both setters skip the equal dispatch, with every call site unchanged — verified (
packages/core/src/Text/useTruncation.ts:79-96,:141,:200). - A
[fix]changeset is included — verified; its category is the note above. - Consumer suites pass (Text, Heading, Lightbox, Table, Lab LineClamp and the CLI's truncation-hook template test; 61 files, 1,476 tests) and typecheck and lint are clean — verified (60 files and 1,474 tests, plus 1 file and 2 tests;
pnpm -F @astryxdesign/core typecheckand ESLint on the changed file both pass). - No jsdom red test is possible, because React drops a same-value update before it renders — verified: render counts are identical for the base and the head hook while dispatch counts differ.
- One hook file, with no API, record or output change — verified: the repository's own API generator reports no row from this patch.
- The release note's claim that the hook returns the same values as before — verified by the probe above.
- Public text contains no internal context — verified by a scan of the title, body, branch, commit message and every added line.
Files:
packages/core/src/Text/useTruncation.ts— clear, with the INV10 reporting gap above and the duplicate-helper note..changeset/text-truncation-no-op-dispatch.md— the category note above; the sentence itself is accurate.
| // sets nothing, so a list that mounts many texts dispatches no updates | ||
| // that would change nothing. | ||
| const shownRef = useRef({isTruncated: false, fullText: ''}); | ||
| const setIsTruncated = useCallback((value: boolean) => { |
There was a problem hiding this comment.
Non-blocking: packages/core/src/hooks/useScrollableArea.ts:208 already has setIfChanged(last, set, value) with the same body and the same reason in its comment. One shared helper under hooks/ would keep the two from drifting.
The changeset is a performance change with identical returned values, so it opens [perf].
|
/approve-spec 6fc52db |
There was a problem hiding this comment.
Approved pending CI: CI is still running on this head; lint, typecheck, build, visual regression and most test shards have passed.
The touched-components audit failed when its repository checkout timed out, before any audit ran, so it needs a re-run; nothing in this change causes it.
The patch is unchanged since the last review, and the hook still returns the same values at the same times while skipping updates that would change nothing.
- Non-blocking:
packages/core/src/hooks/useScrollableArea.tsalready has a privatesetIfChangedwith the same body as the new setters, so one shared helper underhooks/would keep the two from drifting.
Claims and files checked
Review mode: same-head; reason: none
- Changed rules (0): none.
- Claims:
- Title, a measurement that finds the same result sets no state: verified,
useTruncation.ts:85-96skips a value equal to the one last set. - Release note, an unchanged measurement no longer schedules a state update: verified,
useTruncation.ts:85-96. - Release note,
useTruncationreturns the same values as before: verified, every dispatch is a plain value, so skipping an equal one never changes the committed state; the consumer suites pass. - Release note, a patch note filed under Performance: verified,
perfis one of the repository's changeset categories and the changeset check passes. - Description, wide windowed Tables render each default cell as a single-line truncating Text: verified,
Table/BaseTable.tsx:277. - Description, before this change every measurement set both values even when unchanged: verified against the merge base's unconditional setter calls.
- Description, after it a same-value measurement dispatches nothing and the hook's output and timing are unchanged: verified,
useTruncation.ts:79-201. - Description, the remaining updates are each new cell's first text and the reset when an element detaches: verified from the code paths.
- Description, real-browser update counts and timings per range step, alone and combined with the companion changes: not reproduced here (they need a real-browser harness and the companion pull requests); consistent with the code.
- Description, the column-windowing timing target it cites (range at most 4 ms and no-op at most 2 ms at 1,000 columns): verified, it matches the Table column-virtualization record's timing target, which this pull request does not claim on its own.
- Description, first-load gzip deltas on the four reference pages, each inside the 0.3 KB allowance: verified within compressor variance, +37, +36, +36 and +40 B here.
- Description, the consumer suites (61 files, 1,476 tests), typecheck and lint pass: verified on this head.
- Description, jsdom cannot see these dispatches: consistent with React's eager bailout; no render count changes there.
- Description, one hook file with no API, record or output change: verified; the API change report lists no row.
- Description, the overlapping server-rendering change also touches this hook: verified.
- Description, public text carries no internal context: verified.
- Description, the land path (approval of this head, the spec stamp, CI, then the merge queue): consistent; the spec stamp for this head is present.
- Title, a measurement that finds the same result sets no state: verified,
- Files:
packages/core/src/Text/useTruncation.ts: clear, with the non-blocking helper note above..changeset/text-truncation-no-op-dispatch.md: clear.
User impact
<Text maxLines={1}>).useTruncationran set itsisTruncatedandfullTextstate, even when the values were unchanged. A Table column range step dispatched about 119 such updates (real-Chrome stack probe on a 1,000-column table), including updates on the cells being removed.useTruncation's public return is identical:isTruncatedandfullTexthold exactly the values they held before, at the same times. Only no-op dispatches go away.What changed
Text/useTruncation.ts: the hook keeps the values it last set as state in a ref, and its two setters skip the dispatch when the new value equals that one. Every call site keeps its value and timing.[perf]changeset.Evidence
architecture:component-import-boundariesINV10;useTruncation.tsis shared by Text, Heading, Lightbox and Lab's LineClamp),pnpm size:pagesfrom the merge base 344ec5b, gzip: docs +30 B, form +42 B, menu +32 B, table +43 B, each inside INV10's 0.3 KB allowance.useTruncation.test.tsx), Heading, Lightbox, Table, Lab LineClamp, and the CLI'suse-truncation-hook-usagetemplate test (61 files, 1,476 tests). tsc and eslint are clean.The remaining ~40 are real value changes: each newly mounted cell's first
fullText, and the reset when a cell's element detaches. Both are kept, so the hook's output is unchanged.In the same measurement, the windowed range step's production scripting p95 fell from 5.06–5.37 ms to 4.11–4.29 ms with this pull request and perf(Table): pinned offsets are computed once per column list, not once per cell #11893 together.
Combined timing (
module:Table/useTableColumnsVirtualizationPR3: range ≤ 4 ms, no-op ≤ 2 ms). Setup: a local production Storybook build of a 1,000-column × 20-row column-windowed story, Chrome 149 headed, 1280 × 900, 1× CPU, dev-only instrumentation off, 300 range and 120 no-op steps per run. With fix(Table): when only its columns window, a scroll that keeps its columns commits nothing #11844, perf(Table): pinned offsets are computed once per column list, not once per cell #11893, perf(Text): a truncation measurement that finds the same result sets no state #11911 and perf(Table): a default cell measures its truncation on first hover or focus #11933 together:On both farm hosts the range step costs about half of main's, with one commit per range step (main: 3). On the release check's runner, which decides PR3, the four together meet it: range-plus-commit p95 3.5 ms (≤ 4) and no-op p95 0.1 ms (≤ 2), measured with the Table release proof's own scroll-to-commit probe in one gated run. The last of the four to land claims PR3.
Scope
Overlap checked: #11105 (it moves Text and Heading toward server rendering and touches
useTruncation.tsfor that; this changes only when the hook's setters dispatch)Owner: Astryx fix-loop lane 0. Land path: CodeBunny approval of the exact head, Specs stamp, CI, then the merge queue.