-
Notifications
You must be signed in to change notification settings - Fork 138
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
Analyze React+Redux perf timings using recording analysis #9410
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@markerikson packages/replay-next meant Next.js exclusive package? |
@ryota-murakami : no. All our app source code originally lived in the |
I just updated this to capture details on the start and end of the related React commit, plus counts of how many function and class components got rendered overall: as well as inspecting the rendered components and determining the details for each unique component type: This gives us a foundation for being able to do real-world React render performance analysis, on production apps, no further profiling setup needed! |
@markerikson Great Job!
Might be this tweet 😅 https://twitter.com/brian_d_vaughn/status/1674214956668014593 |
97efb33
to
92c1d77
Compare
Is this worth keeping open as a draft or was it just something you wanted to test/share? |
Keep it as a draft for now. Like the other "React Render" panel, it's something I intend to merge and feature flag, but I need to do some cleanup before it's ready to at least have in the codebase. |
Cleaning up the PR queue by closing old/stale PRs. Re-open it once it's ready to be reviewed :) |
Time to play with this again... |
92c1d77
to
31ee225
Compare
There's a lot of conceptual overlap between what I was doing in the first iteration of this "Redux+React Perf Profiler" PR, and what I did in the original POC for the "React Render Timeline" panel. Both rely on fetching hit points for internals. Both require fetching points for the current focus window. And my POC for the Redux perf work wanted to know when React had rendered, and when we queued renders, so that we could know if the dispatch did actually result in components rendering. Over this weekend, I've updated this PR:
The result is that the React Render Timeline is showing up significantly faster (5-10s for several hundred hits), whereas before it would take seemingly forever for values to slowly come in. I don't have any UI for the Redux data yet, but that should be trivial to add now that I've got the cache for the values. From there, the next step would be to start adding logic to query for perf stats related to a given dispatch: was a render queued, how long did it take, how many components rendered, how long did those take, which ones were most expensive, and what selectors ran and their timings. Rather than fetch all of that up front, fetching it for just one render ought to be reasonably faster. Here's what the render timeline looks like atm: |
I've finally built out some UI for the Redux Dispatch Perf panel: things I can now do with this info:
and similarly, with React renders, I could pull together info on:
I know there's all kinds of caveats on sync renders vs concurrent rendering, components being thrown away, etc. Not anywhere close to being a "real" profiler. But I've got demo code (even if commented out atm) that shows I can get plausible interpretations of that info. So it's a starting point. |
03cde37
to
54a8142
Compare
ffd13af
to
c0125c3
Compare
2712e64
to
fa1db6b
Compare
This PR:
useSelector
useSelector
dispatch()
start/end times, and groups all the selector calls, notification calls, and queued re-renders triggered by that dispatchIn other words, this is a major first step towards a useful React+Redux perf analysis tool.
Caveats:
Debugger.findStepOutTarget
to determine the execution time for a couple thousand function calls.It's very likely that the execution speed would be faster if we moved this into a backend postprocessing routine, and also added some additional backend APIs to allow requesting step-out results in batches instead of individual requests.
Here's an example of what the output looks like for a given dispatch in our own front-end codebase:
That one dispatch:
connect
components notifying their children