Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fiber] Log Component Effects to Performance Track #30983

Merged
merged 4 commits into from
Sep 17, 2024

Conversation

sebmarkbage
Copy link
Collaborator

Stacked on #30981. Same as #30967 but for effects.

This logs a tree of components using performance.measure().

In addition to the previous render phase this logs one tree for each commit phase:

  • Mutation Phase
  • Layout Effect
  • Passive Unmounts
  • Passive Mounts

I currently skip the Before Mutation phase since the snapshots are so unusual it's not worth creating trees for those.

The mechanism is that I reuse the timings we track for enableProfilerCommitHooks. I track first and last effect timestamp within each component subtree. Then on the way up do we log the entry. This means that we don't include overhead to find our way down to a component and that we don't need to add any additional overhead by reading timestamps.

To ensure that the entries get ordered correctly we need to ensure that the start time of each parent is slightly before the inner one.

Copy link

vercel bot commented Sep 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 17, 2024 8:03pm

@react-sizebot
Copy link

react-sizebot commented Sep 17, 2024

Comparing: 15da917...ea5e88e

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.68 kB 6.68 kB = 1.82 kB 1.82 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 508.59 kB 508.56 kB = 91.04 kB 91.03 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 513.49 kB 513.49 kB = 91.74 kB 91.74 kB
facebook-www/ReactDOM-prod.classic.js = 602.95 kB 602.92 kB = 106.73 kB 106.73 kB
facebook-www/ReactDOM-prod.modern.js = 579.18 kB 579.18 kB = 102.85 kB 102.85 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/react-reconciler/cjs/react-reconciler.profiling.js +0.72% 410.49 kB 413.46 kB +0.55% 67.23 kB 67.60 kB
oss-experimental/react-art/cjs/react-art.development.js +0.60% 557.67 kB 561.00 kB +0.46% 90.43 kB 90.84 kB
oss-experimental/react-dom/cjs/react-dom-profiling.profiling.js +0.51% 539.26 kB 542.02 kB +0.35% 96.24 kB 96.57 kB
oss-experimental/react-reconciler/cjs/react-reconciler.development.js +0.50% 639.33 kB 642.51 kB +0.35% 102.93 kB 103.29 kB
oss-experimental/react-dom/cjs/react-dom-client.development.js +0.34% 942.77 kB 945.96 kB +0.22% 159.77 kB 160.12 kB
oss-experimental/react-dom/cjs/react-dom-profiling.development.js +0.34% 959.16 kB 962.40 kB +0.22% 162.59 kB 162.95 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.development.js +0.33% 959.71 kB 962.89 kB +0.22% 163.58 kB 163.94 kB

Generated by 🚫 dangerJS against 3eb822c

This lets us build up a tree of effects.
To ensure that parent comes first we subtrack a little bit when we bubble
the start time.
It's getting a lot to duplicate.
@sebmarkbage sebmarkbage merged commit e1c2090 into facebook:main Sep 17, 2024
184 checks passed
github-actions bot pushed a commit that referenced this pull request Sep 17, 2024
Stacked on #30981. Same as #30967 but for effects.

This logs a tree of components using `performance.measure()`.

In addition to the previous render phase this logs one tree for each
commit phase:

- Mutation Phase
- Layout Effect
- Passive Unmounts
- Passive Mounts

I currently skip the Before Mutation phase since the snapshots are so
unusual it's not worth creating trees for those.

The mechanism is that I reuse the timings we track for
`enableProfilerCommitHooks`. I track first and last effect timestamp
within each component subtree. Then on the way up do we log the entry.
This means that we don't include overhead to find our way down to a
component and that we don't need to add any additional overhead by
reading timestamps.

To ensure that the entries get ordered correctly we need to ensure that
the start time of each parent is slightly before the inner one.

DiffTrain build for [e1c2090](e1c2090)
sebmarkbage added a commit that referenced this pull request Sep 17, 2024
Stacked on #30983.

This colors each component entry by its self time from light to dark
depending on how long it took. If it took longer than a cut off we color
it red (the error color).

<img width="435" alt="Screenshot 2024-09-16 at 11 48 15 PM"
src="https://github.com/user-attachments/assets/5d0bda83-6205-40e9-bec1-b81db2d48b2d">
github-actions bot pushed a commit that referenced this pull request Sep 17, 2024
Stacked on #30983.

This colors each component entry by its self time from light to dark
depending on how long it took. If it took longer than a cut off we color
it red (the error color).

<img width="435" alt="Screenshot 2024-09-16 at 11 48 15 PM"
src="https://github.com/user-attachments/assets/5d0bda83-6205-40e9-bec1-b81db2d48b2d">

DiffTrain build for [8dfbd16](8dfbd16)
sebmarkbage added a commit to sebmarkbage/react that referenced this pull request Nov 12, 2024
sebmarkbage added a commit that referenced this pull request Nov 12, 2024
This reverts commit d3bf32a which was
part of #30983

When you have very deep trees this trick can cause the top levels to
skew way too much from the real numbers. Creating unbalanced trees.

The bug should have been fixed in Chrome Canary now so that entries
added later are sorted to go first which should've addressed this issue.
sebmarkbage added a commit that referenced this pull request Dec 18, 2024
In #30967 and
#30983 I added logging of the just
rendered components and the effects. However this didn't consider the
special Offscreen passes. So this adds the same thing to those passes.

Log component effect timings for disconnected/reconnected offscreen
subtrees. This includes initial mount of a Suspense boundary.

Log component render timings for reconnected and already offscreen
offscreen subtrees.
github-actions bot pushed a commit that referenced this pull request Dec 18, 2024
In #30967 and
#30983 I added logging of the just
rendered components and the effects. However this didn't consider the
special Offscreen passes. So this adds the same thing to those passes.

Log component effect timings for disconnected/reconnected offscreen
subtrees. This includes initial mount of a Suspense boundary.

Log component render timings for reconnected and already offscreen
offscreen subtrees.

DiffTrain build for [6a4b46c](6a4b46c)
github-actions bot pushed a commit that referenced this pull request Dec 18, 2024
In #30967 and
#30983 I added logging of the just
rendered components and the effects. However this didn't consider the
special Offscreen passes. So this adds the same thing to those passes.

Log component effect timings for disconnected/reconnected offscreen
subtrees. This includes initial mount of a Suspense boundary.

Log component render timings for reconnected and already offscreen
offscreen subtrees.

DiffTrain build for [6a4b46c](6a4b46c)
github-actions bot pushed a commit to code/lib-react that referenced this pull request Dec 18, 2024
…ok#31788)

In facebook#30967 and
facebook#30983 I added logging of the just
rendered components and the effects. However this didn't consider the
special Offscreen passes. So this adds the same thing to those passes.

Log component effect timings for disconnected/reconnected offscreen
subtrees. This includes initial mount of a Suspense boundary.

Log component render timings for reconnected and already offscreen
offscreen subtrees.

DiffTrain build for [6a4b46c](facebook@6a4b46c)
github-actions bot pushed a commit to code/lib-react that referenced this pull request Dec 18, 2024
…ok#31788)

In facebook#30967 and
facebook#30983 I added logging of the just
rendered components and the effects. However this didn't consider the
special Offscreen passes. So this adds the same thing to those passes.

Log component effect timings for disconnected/reconnected offscreen
subtrees. This includes initial mount of a Suspense boundary.

Log component render timings for reconnected and already offscreen
offscreen subtrees.

DiffTrain build for [6a4b46c](facebook@6a4b46c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants