-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
core(tracehouse): expose navigationStart only as timeOrigin #11034
Conversation
Friendly ping |
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.
except one bug fix in asset-saver
what was this fix? Did it have to do with the pwmetrics-events
change?
I'm not sure if I see a completely smooth transition for all of trace-processor in the future (going back to no FCP is an issue in a lot of places, for instance) and the loss of the self-documenting name is kind of a downer, but it seems necessary. LGTM
@@ -57,14 +57,14 @@ function getChildTask({ts, duration, url}) { | |||
* Creates a simple trace that fits the desired options. Useful for basic trace | |||
* generation, e.g a trace that will result in particular long-task quiet | |||
* periods. Input times should be in milliseconds. | |||
* @param {{navigationStart?: number, traceEnd?: number, topLevelTasks?: Array<TopLevelTaskDef>}} options |
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.
since this is making a navigationStart
event out of this timestamp, seems like it should stay navigationStart
? And then generalize if/when we need this to generate traces without a navStart
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.
Hm, not sure I agree here. The primary goal after this change is to have all the places where we say navigationStart
do so because conceptually they absolutely require a navigationStart
event and not just a timeOrigin
timestamp.
All the places where we use createTestTrace today don't need absolutely require a navigationStart event (other than the fact that it's an implementation detail of determining our timeOrigin at this moment), they're just trying to set the timeOrigin. If and when we have tests that explicitly require a navigationStart event because it's the only thing that allows the computation to work, then I agree we should reintroduce navigationStart
as a secondary option in this object.
I guess what I'm saying is, everything that sets navigationStart
in createTestTrace
today would be fine if we replaced the navigationStart
event with say FetchStart
if it were the timeOriginEvt
in TraceProcessor.
Does that make sense?
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.
Does that make sense?
I still disagree, but too late now :P
I guess what I'm saying is, everything that sets navigationStart in createTestTrace today would be fine if we replaced the navigationStart event with say FetchStart if it were the timeOriginEvt in TraceProcessor.
but not a user timing event.
We don't have a definition for TTI for an arbitrary starting point since it requires FCP and DCL. By removing specificity we make every instance of timeOrigin
into a hunt into other files for where the trace came from and/or what starting point we were interested in (instead of just saying, oh, yeah, navStart and moving on in the code). Instead I think it's better to stay specific whenever possible (like in test code for tests explicitly written based on navStart) and only get general when we need to be (e.g. in the case of create-test-trace
, navigationStart
could have been made optional and other possible origins added, with the generated trace adapted depending on which one is used)
if (!timeOriginMetric) return; | ||
try { | ||
const frameIds = TraceProcessor.findMainFrameIds(this._traceEvents); | ||
return {pid: frameIds.pid, tid: frameIds.tid, ts: timeOriginMetric.ts}; |
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.
what's going on with this change vs what it does today?
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.
before it was kind of abusing navstart to also reuse the main frame ids for other metric markers, this makes the connection more explicit that we really just want the time origin timestamp and main frame pid/tid
/** @param {number=} ts */ | ||
const maybeGetTiming = (ts) => ts === undefined ? undefined : getTiming(ts); | ||
/** @type {TraceTimesWithoutFCP} */ | ||
const timings = { | ||
navigationStart: 0, | ||
timeOrigin: 0, |
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.
imagining future uses of this with non-navStart-timeOrigins, seems like we're still going to want a navStart entry? Though maybe it should be more specific, like lastNavigationStart
or something.
One thing this would help with is answering the question "what's the timeOrigin
being used here?". At the very least, you'd be able to compare it against navStart and see that they're equal.
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.
imagining future uses of this with non-navStart-timeOrigins, seems like we're still going to want a navStart entry?
Maybe. But there are certainly cases where there will be 0 navStart entries to return, and I'd rather reintroduce navStart into this chain only where absolutely necessary (similar to above explanation).
Though maybe it should be more specific, like lastNavigationStart or something.
That makes sense to me though I'm not sure anything at all would use it right now. Are you OK holding off on this one until we have the first case where something needs it to better understand the requirements?
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.
Maybe. But there are certainly cases where there will be 0 navStart entries to return, and I'd rather reintroduce navStart into this chain only where absolutely necessary (similar to above explanation).
It doesn't make sense to me to try to be general in solution but not report on navigationStart
(if found in the trace), but I guess we'll wait for when it's needed.
One thing this PR makes harder to address is still the "what's the timeOrigin being used here?" question, though.
correct, the pwmetrics-events was erroring on traces from asset-saver until the explicit mainframe id change I made here |
For reference, it's mostly inherent complexity but it suuucks that the answer to "when is
https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp#The_time_origin and that's without a user also able to pick an arbitrary point in time :) So hopefully we can come up with a good way that it can be figured out at any point in the pipeline. |
Summary
First of several refactors to reduce our dependence on
navigationStart
as a foundation for all lighthouse trace work. This PR renames the exported property from trace-processor.js fromnavigationStart
totimeOrigin
but leaves thetimeOrigin
value asnavigationStart
. has no effect on behavior (except one bug fix in asset-saver) and is purely naming to enhance the clarity throughout the codebase of where we use navigationStart only as a timeOrigin and when we use it because we really need navigationStart.Future Work
timeOrigin
out from the main trace processing.Related Issues/PRs
ref #10325 #9519 #1769 #8984