core(tracehouse): expose navigationStart only as timeOrigin#11034
Conversation
|
Friendly ping |
brendankenny
left a comment
There was a problem hiding this comment.
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
| * 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.
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.
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.
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.
what's going on with this change vs what it does today?
There was a problem hiding this comment.
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
| /** @type {TraceTimesWithoutFCP} */ | ||
| const timings = { | ||
| navigationStart: 0, | ||
| timeOrigin: 0, |
There was a problem hiding this comment.
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.
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.
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
navigationStartas a foundation for all lighthouse trace work. This PR renames the exported property from trace-processor.js fromnavigationStarttotimeOriginbut leaves thetimeOriginvalue 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
timeOriginout from the main trace processing.Related Issues/PRs
ref #10325 #9519 #1769 #8984