Skip to content

perf: add a case for many hooks called#2443

Merged
HuJean merged 1 commit intomainfrom
p/usestate
Apr 11, 2026
Merged

perf: add a case for many hooks called#2443
HuJean merged 1 commit intomainfrom
p/usestate

Conversation

@HuJean
Copy link
Copy Markdown
Collaborator

@HuJean HuJean commented Apr 11, 2026

Summary by CodeRabbit

  • Chores
    • Added a new React performance benchmark case that mounts many stateful components to exercise rendering and hydration behavior.
    • Updated build configuration and npm scripts to enable running and profiling the new benchmark.
    • Added a new changeset placeholder file.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).
  • Changeset added, and when a BREAKING CHANGE occurs, it needs to be clearly marked (or not required).

@HuJean HuJean requested a review from hzy as a code owner April 11, 2026 05:50
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 11, 2026

🦋 Changeset detected

Latest commit: 8fbe2a0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 63e6ef6f-be58-49e6-aaf4-5dcca208d700

📥 Commits

Reviewing files that changed from the base of the PR and between 986a879 and 8fbe2a0.

📒 Files selected for processing (4)
  • .changeset/calm-zebras-smile.md
  • benchmark/react/cases/008-many-use-state/index.tsx
  • benchmark/react/lynx.config.js
  • benchmark/react/package.json
✅ Files skipped from review due to trivial changes (2)
  • .changeset/calm-zebras-smile.md
  • benchmark/react/package.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • benchmark/react/lynx.config.js
  • benchmark/react/cases/008-many-use-state/index.tsx

📝 Walkthrough

Walkthrough

Adds a new React benchmark case 008-many-use-state, registers it in the benchmark build config, adds npm scripts to run it (bench and perfetto), and adds an empty changeset file.

Changes

Cohort / File(s) Summary
Changeset
.changeset/calm-zebras-smile.md
Added an empty changeset markdown file containing only YAML front matter (--- block) with no metadata.
Benchmark case
benchmark/react/cases/008-many-use-state/index.tsx
New Lynx React benchmark: renders 1000 Item components; each Item calls useState(0) and conditionally renders <text> when state equals 1; benchmark mounted via runAfterLoadScript and root.render.
Build & scripts
benchmark/react/lynx.config.js, benchmark/react/package.json
Added 008-many-use-state build entry and two npm scripts: bench:008-many-use-state and perfetto:008-many-use-state to run the generated bundle and produce a perfetto trace.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • hzy

Poem

🐰 I nibble bytes and count each state,
A thousand hops arranged in straight,
I wait to render just one sight,
Then watch the tiny carrot light.
🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'perf: add a case for many hooks called' directly and specifically describes the main change: adding a new benchmark case for testing many useState hooks, which is evident from the changeset files and benchmark configuration additions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch p/usestate

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 and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 11, 2026

Merging this PR will degrade performance by 10.28%

❌ 1 regressed benchmark
✅ 71 untouched benchmarks
🆕 9 new benchmarks
⏩ 21 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
🆕 008-many-use-state/main-thread.js_LoadScript N/A 393.9 µs N/A
🆕 008-many-use-state/background.js_LoadScript N/A 500.1 µs N/A
🆕 008-many-use-state__main-thread-renderMainThread N/A 80.2 ms N/A
🆕 008-many-use-state-renderBackground N/A 52.3 ms N/A
🆕 008-many-use-state__main-thread-renderOpcodes N/A 21.7 µs N/A
transform 1000 view elements 40.4 ms 45 ms -10.28%
🆕 008-many-use-state-destroyBackground N/A 8 ms N/A
🆕 008-many-use-state__main-thread-processData N/A 23.5 µs N/A
🆕 008-many-use-state-hydrate N/A 483.5 µs N/A
🆕 008-many-use-state__main-thread-serializeRoot N/A 148.5 µs N/A

Comparing p/usestate (8fbe2a0) with main (5151fcf)

Open in CodSpeed

Footnotes

  1. 21 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@relativeci
Copy link
Copy Markdown

relativeci bot commented Apr 11, 2026

React External

#309 Bundle Size — 590.13KiB (0%).

8fbe2a0(current) vs 5151fcf main#294(baseline)

Bundle metrics  no changes
                 Current
#309
     Baseline
#294
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 3 3
No change  Modules 17 17
No change  Duplicate Modules 5 5
No change  Duplicate Code 8.59% 8.59%
No change  Packages 0 0
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#309
     Baseline
#294
No change  Other 590.13KiB 590.13KiB

Bundle analysis reportBranch p/usestateProject dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci bot commented Apr 11, 2026

React MTF Example

#324 Bundle Size — 206.11KiB (0%).

8fbe2a0(current) vs 5151fcf main#309(baseline)

Bundle metrics  no changes
                 Current
#324
     Baseline
#309
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 3 3
No change  Modules 173 173
No change  Duplicate Modules 67 67
No change  Duplicate Code 45.76% 45.76%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#324
     Baseline
#309
No change  IMG 111.23KiB 111.23KiB
No change  Other 94.88KiB 94.88KiB

Bundle analysis reportBranch p/usestateProject dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci bot commented Apr 11, 2026

Web Explorer

#8765 Bundle Size — 743.45KiB (0%).

8fbe2a0(current) vs 5151fcf main#8751(baseline)

Bundle metrics  no changes
                 Current
#8765
     Baseline
#8751
No change  Initial JS 43.82KiB 43.82KiB
No change  Initial CSS 2.16KiB 2.16KiB
Change  Cache Invalidation 0% 28.41%
No change  Chunks 8 8
No change  Assets 10 10
No change  Modules 149 149
No change  Duplicate Modules 11 11
No change  Duplicate Code 34.96% 34.96%
No change  Packages 3 3
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#8765
     Baseline
#8751
No change  Other 398.15KiB 398.15KiB
No change  JS 343.13KiB 343.13KiB
No change  CSS 2.16KiB 2.16KiB

Bundle analysis reportBranch p/usestateProject dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci bot commented Apr 11, 2026

React Example

#7191 Bundle Size — 236.82KiB (0%).

8fbe2a0(current) vs 5151fcf main#7176(baseline)

Bundle metrics  no changes
                 Current
#7191
     Baseline
#7176
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 4 4
No change  Modules 179 179
No change  Duplicate Modules 70 70
No change  Duplicate Code 46.1% 46.1%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#7191
     Baseline
#7176
No change  IMG 145.76KiB 145.76KiB
No change  Other 91.06KiB 91.06KiB

Bundle analysis reportBranch p/usestateProject dashboard


Generated by RelativeCIDocumentationReport issue

@HuJean HuJean force-pushed the p/usestate branch 2 times, most recently from b1f6a26 to 986a879 Compare April 11, 2026 06:27
@HuJean HuJean merged commit dc3b6e0 into main Apr 11, 2026
77 of 80 checks passed
@HuJean HuJean deleted the p/usestate branch April 11, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants