-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
cmd/trace: add absolute (system) timestamp #69869
Comments
(I don't know if this needs to be a proposal. It's not really a noteworthy feature, as it's an optional addition and only concerns very few users of a sub-tool, please adjust accordingly.) |
In the new trace format, we do usually store absolute (monotonic) timestamps. The start of each batch has the full absolute timestamp. Each event within the batch contains the time delta from the previous event. The exception is Windows, where time has low resolution, so in that case we use CPU ticks (RDTSC). cc @felixge |
That's nice. I don't know much about catapult, but could it be made to display things in absolute time? |
In theory, I believe this field just needs to be in absolute time: https://cs.opensource.google/go/go/+/master:src/internal/trace/traceviewer/format/format.go;l=25;drc=70f4717e96cf9d8ca8a5f439d7d6487ec822ce49;bpv=1;bpt=1 The current values tend to just come from computations like https://cs.opensource.google/go/go/+/master:src/cmd/trace/goroutinegen.go;l=137;drc=70f4717e96cf9d8ca8a5f439d7d6487ec822ce49;bpv=1;bpt=1, which currently are The format says the time should be in microseconds. I don't know how nicely Catapult will display the values, given they will probably be huge. |
That's just reading AFAICT. I spent some time looking for writing and found Lines 57 to 62 in f2d118f
nanotime is (on Linux)
The absolute value can thus be calculated if we knew the time since boot. But I haven't been able to find that anywhere in a trace. Did I miss it? |
I think I am confused by what you mean by "absolute time". I thought that meant you wanted the CLOCK_MONOTONIC value, which we have. Do you actually mean the CLOCK_REALTIME value (wall time)? We don't record that. I don't think that would be as useful for correlation with other trace events on the machine, since the real time clock can change arbitrarily. |
For correlation with other trace events on the machine, In my case, I don't always:
Specifically, I get a crash which has exported a trace around crash time using the flight recorder. The monitoring service tells me the crash timestamp is It seems to me like this could be solved by (also) adding a timestamp relative to the UNIX epoch in every generation event. Then, tooling ( That, or I'm missing something that currently exists, or a different way to correlate the data I want. Any ideas? |
That makes sense. There is a caveat that it will probably be difficult to precisely line up events using wall time, but I agree it would be useful even just for getting a vague sense of where within logs, etc the trace occurs (within a few hundred ms). I think including a real time timestamp in each generation would be reasonable. I think that would be sufficient. If the real time clock changes during tracing then computed timestamps may be wrong, but that should be rare. |
(cc @mknyszek for thoughts on including a real time timestamp in each generation) |
Up to a few hundred ms is much better than what's currently available. It would already help me. I wonder how easy it is to get the equivalent of |
|
We could just add this as a new event type that always lives in the same batch as With respect to exposing this in the trace API, the easiest thing to do would be to make it a property of the |
I don't think this needs to be a proposal. The trace parsing API is still experimental. |
I don't know much about this, but this sounds contradictory, unless internal trace events and trace API events are fully decoupled. In which case, SGTM. |
Sorry, yes. They are completely decoupled. The |
Proposal Details
Runtime traces don't contain (or display) an absolute timestamp for events. This would be useful for comparing traces with other (tracing) tools, logs et cetera.
An example would be combining a Go runtime trace with perf sched events. This would allow better investigation of kernel scheduling events and how they impact the latency of goroutines.
IIRC, runtime traces currently use a relative (monotonic) timestamps for performance reasons. It's fine to keep this as-is. But it would be helpful if (e.g.) the start of a trace batch could contain an absolute system time (perhaps something lie nanoseconds since the UNIX epoch) together with the relative timestamp it was derived from. Tools like
go tool trace
could then adjust all the relative timestamps post-hoc, or at least display the trace start and end time.cc @mknyszek
The text was updated successfully, but these errors were encountered: