-
Notifications
You must be signed in to change notification settings - Fork 569
Profiler RFC #51
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
Merged
+141
−0
Merged
Profiler RFC #51
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
317e02a
Profiler RFC
dfe022f
Unresolved questions
58afaa1
Formatting nits
b529613
Organizational tweask
1475772
Added an async caveat about actual time
7cb55e6
Typofix
3e9edf1
Added clarfiication note about how <Profiler> works in production bundle
6062c52
Typofix
b1834f9
Renamed actualTime -> actualDuration and baseTime -> baseDuration
c263445
Updated note about Profiler experimental release
a5c38f4
Added interaction-tracking proposal to RFC
009a0b4
Udpated RFC
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Renamed actualTime -> actualDuration and baseTime -> baseDuration
- Loading branch information
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not pass all of this as a single object so people can pick out the keys they need?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reasonable question!
I'd say the reasons are that I'm following precedent (we don't pass named parameters anywhere else that I can think of off the top of my head) and avoiding allocating a wrapper Object during commit.
I'd be interested to hear what others think about this aspect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd vote for an object, despite the fact that it breaks with existing React API precedent.
The order of these timing arguments is going to be tough to memorize, and I can imagine only being interested in a subset of them. Using an object also enables you to add additional timing data down the road.
I'd view it as somewhat analogous to an event object, which has a variety of keys, only some of which are of interest for any given listener.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would you need to memorize it? I imagine you'd only use Profiler in a few places in the app, and each time could consult the docs.
The need to avoid allocations is pretty important because adding GC pressure can skew the profiling results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if you use
Profilerin more than one place, the callback you pass it is likely shared- (this is why theidparameter exists)- so you would only need to write these params (in the correct order) in a single place.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, this concern makes sense. And I agree that we wouldn't be allocating too many new objects for this, because it would only be one per
Profilerper commit. I was just sharing rationale for why it is currently the way it is.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just my personal opinion here, but an object looks good from my point of view as long functions with more that 2/3 args are always hard to remember, you tend to start adding
nullfor the values that you might not want to use, I'm looking at youJSON.stringify(foo, null, 2)😅 , you also need to remember the order and it's harder to refactor as you impact anyone already using that order.Plus with the actual syntax for destructuring the function signature looks pretty much the same but with curly braces 😁, the best of two worlds!
vs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that the Profiling API is out in the 16.4.1 release, I assume you decided to take no action on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
unstable_Profilercomponent was introduced in 16.4.0. The only thing that's new in 16.4.1 is a production+profiling build.Unstable APIs can change. We haven't decided one way or another. This is kind of an open thread for discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just circling back on this particular thread. Sebastian and I chatted about this yesterday, and we've decided to avoid named parameters because the overhead of the wrapper objects (however small each individual one is) will add up in larger applications.