-
Notifications
You must be signed in to change notification settings - Fork 30.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
Add trace_events Clock Sync Event for Date.now() and hrtime() #17349
Comments
You mean adding a |
Oh, brilliant. I was looking to see if we had the macro but I couldn't find it. This makes it much easier. |
As suspected it is not implemented: node/src/tracing/trace_event.h Line 213 in 212b12c
|
Curious, it exists in deps/v8/base: node/deps/v8/base/trace_event/common/trace_event_common.h Lines 922 to 926 in 4ca4db0
Time to sync up again, I suppose? cc @matthewloring - do you still work on tracing? |
should I add something to |
@bnoordhuis It is |
Definitely +1 on this. @bnoordhuis ... the trace events implementation in core was never completed and has quite a bit that has not been implemented yet. Specifically, none of the @matthewloring moved on to a different role within Google. |
Hi Folks! 👋 Sorry for the late reply @matthewloring was previously working on trace events, but since he is no longer working on the same team, @kjin and I are ramping up on the trace event implementation. There have been some changes made upstream to make it easier for embedders to reuse the libplatform implementation of tracing controller rather than having to duplicate. See changes on this bug: https://bugs.chromium.org/p/v8/issues/detail?id=6511. @kjin and I are presently digesting this to understand how this could be utilized over in node. |
For now, I would recommend to just sync the trace_event_common.h file as that macro does not require any changes on the back-end since it uses an existing internal macro. Meanwhile, I will check with @ofrobots if we can reuse the existing file from V8 directly now since some parts have already been exposed. |
Hi Folks. I have been doing some research, and here are my findings based on the Trace Event Clock Sync design document. As far as I understand the
Can you elaborate a little bit more on where/how you saw the timestamps to differ? Trace events timestamps are based on the V8 There are a few ways I can think we can fix things:
The latter would be something along the lines of: "traceEvents": [
{
"pid": 59661,
"tid": 775,
"ts": 220620843754,
"tts": 5072,
"ph": "X",
"cat": "__metadata",
"name": "clock sync",
"dur": 16,
"tdur": 8,
"args": {
"process.hrtime()": 220620843715826
}
}
]
} Note that on my system the difference between I'm going to mull over these options and evaluate feasibility, but if anyone has opinions, or if I have understood something incorrectly, please do share your thoughts. |
Another thing to consider here is that at least @jasnell has expressed a desire to be able to use the @jasnell can you elaborate on your use-case for providing own timestamps while I am thinking this over? |
That is the primary use case. As I understand it, the reason why the
Oh, they do appear to match. I confirmed this on Mac. The big issues are then that it is not documented, nor gaurantteed to always align. I could be that they are the same, at least uv_hrtime on windows appears to use
I'm fine with both options, with a slight preference for the first option. |
With the preference for the first option, here's a proposed V8 change that allows embedders (i.e. Node) to provide the backing time source for the trace event timestamps: https://chromium-review.googlesource.com/c/v8/v8/+/847690. Once that is in place, it should be a fairly simple change in Node to start using Assigning issue to self. |
Original commit message: [tracing] allow embedders to provide own tracing timestamps Make it possible for embedders to provide their own tracing timetamps by providing an overridable virtual function on V8's tracing controller. Bug: Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: I727e633cb7f63d4b41c2e427ecca3c9174c90bfe Reviewed-on: https://chromium-review.googlesource.com/847690 Reviewed-by: Yang Guo <[email protected]> Reviewed-by: Fadi Meawad <[email protected]> Commit-Queue: Ali Ijaz Sheikh <[email protected]> Cr-Commit-Position: refs/heads/master@{nodejs#50489} Refs: v8/v8@814577e Refs: nodejs#17349 PR-URL: nodejs#18196 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Andreas Madsen <[email protected]>
Original commit message: [tracing] implement TRACE_EVENT_ADD_WITH_TIMESTAMP Bug: Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: Icb3cf7b7f96704e1eaa4c5fbf773b94b70cddc85 Reviewed-on: https://chromium-review.googlesource.com/861302 Reviewed-by: Fadi Meawad <[email protected]> Reviewed-by: Yang Guo <[email protected]> Commit-Queue: Ali Ijaz Sheikh <[email protected]> Cr-Commit-Position: refs/heads/master@{nodejs#50549} Refs: v8/v8@c3bb73f Refs: nodejs#17349 PR-URL: nodejs#18196 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Andreas Madsen <[email protected]>
Override the V8 TracingController to provide uv_hrtime based timestamps. This allows tracing timestamps to be comparable with process.hrtime timestamps. Fixes: nodejs#17349 PR-URL: nodejs#18196 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Andreas Madsen <[email protected]>
Original commit message: [tracing] allow embedders to provide own tracing timestamps Make it possible for embedders to provide their own tracing timetamps by providing an overridable virtual function on V8's tracing controller. Bug: Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: I727e633cb7f63d4b41c2e427ecca3c9174c90bfe Reviewed-on: https://chromium-review.googlesource.com/847690 Reviewed-by: Yang Guo <[email protected]> Reviewed-by: Fadi Meawad <[email protected]> Commit-Queue: Ali Ijaz Sheikh <[email protected]> Cr-Commit-Position: refs/heads/master@{nodejs#50489} Refs: v8/v8@814577e Refs: nodejs#17349 PR-URL: nodejs#18196 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Andreas Madsen <[email protected]>
Original commit message: [tracing] implement TRACE_EVENT_ADD_WITH_TIMESTAMP Bug: Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: Icb3cf7b7f96704e1eaa4c5fbf773b94b70cddc85 Reviewed-on: https://chromium-review.googlesource.com/861302 Reviewed-by: Fadi Meawad <[email protected]> Reviewed-by: Yang Guo <[email protected]> Commit-Queue: Ali Ijaz Sheikh <[email protected]> Cr-Commit-Position: refs/heads/master@{nodejs#50549} Refs: v8/v8@c3bb73f Refs: nodejs#17349 PR-URL: nodejs#18196 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Andreas Madsen <[email protected]>
Original commit message: [tracing] allow embedders to provide own tracing timestamps Make it possible for embedders to provide their own tracing timetamps by providing an overridable virtual function on V8's tracing controller. Bug: Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: I727e633cb7f63d4b41c2e427ecca3c9174c90bfe Reviewed-on: https://chromium-review.googlesource.com/847690 Reviewed-by: Yang Guo <[email protected]> Reviewed-by: Fadi Meawad <[email protected]> Commit-Queue: Ali Ijaz Sheikh <[email protected]> Cr-Commit-Position: refs/heads/master@{#50489} Refs: v8/v8@814577e Refs: #17349 PR-URL: #18196 Refs: #18360 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Andreas Madsen <[email protected]>
Original commit message: [tracing] implement TRACE_EVENT_ADD_WITH_TIMESTAMP Bug: Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: Icb3cf7b7f96704e1eaa4c5fbf773b94b70cddc85 Reviewed-on: https://chromium-review.googlesource.com/861302 Reviewed-by: Fadi Meawad <[email protected]> Reviewed-by: Yang Guo <[email protected]> Commit-Queue: Ali Ijaz Sheikh <[email protected]> Cr-Commit-Position: refs/heads/master@{#50549} Refs: v8/v8@c3bb73f Refs: #17349 PR-URL: #18196 Refs: #18360 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Andreas Madsen <[email protected]>
Original commit message: [tracing] allow embedders to provide own tracing timestamps Make it possible for embedders to provide their own tracing timetamps by providing an overridable virtual function on V8's tracing controller. Bug: Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: I727e633cb7f63d4b41c2e427ecca3c9174c90bfe Reviewed-on: https://chromium-review.googlesource.com/847690 Reviewed-by: Yang Guo <[email protected]> Reviewed-by: Fadi Meawad <[email protected]> Commit-Queue: Ali Ijaz Sheikh <[email protected]> Cr-Commit-Position: refs/heads/master@{nodejs#50489} Refs: v8/v8@814577e Refs: nodejs#17349 PR-URL: nodejs#18196 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Andreas Madsen <[email protected]>
Original commit message: [tracing] implement TRACE_EVENT_ADD_WITH_TIMESTAMP Bug: Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: Icb3cf7b7f96704e1eaa4c5fbf773b94b70cddc85 Reviewed-on: https://chromium-review.googlesource.com/861302 Reviewed-by: Fadi Meawad <[email protected]> Reviewed-by: Yang Guo <[email protected]> Commit-Queue: Ali Ijaz Sheikh <[email protected]> Cr-Commit-Position: refs/heads/master@{nodejs#50549} Refs: v8/v8@c3bb73f Refs: nodejs#17349 PR-URL: nodejs#18196 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Andreas Madsen <[email protected]>
Override the V8 TracingController to provide uv_hrtime based timestamps. This allows tracing timestamps to be comparable with process.hrtime timestamps. Fixes: nodejs#17349 PR-URL: nodejs#18196 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Andreas Madsen <[email protected]>
Original commit message: [tracing] allow embedders to provide own tracing timestamps Make it possible for embedders to provide their own tracing timetamps by providing an overridable virtual function on V8's tracing controller. Bug: Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: I727e633cb7f63d4b41c2e427ecca3c9174c90bfe Reviewed-on: https://chromium-review.googlesource.com/847690 Reviewed-by: Yang Guo <[email protected]> Reviewed-by: Fadi Meawad <[email protected]> Commit-Queue: Ali Ijaz Sheikh <[email protected]> Cr-Commit-Position: refs/heads/master@{nodejs#50489} Refs: v8/v8@814577e Refs: nodejs#17349 PR-URL: nodejs#18196 Refs: nodejs#18360 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Andreas Madsen <[email protected]>
Original commit message: [tracing] implement TRACE_EVENT_ADD_WITH_TIMESTAMP Bug: Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: Icb3cf7b7f96704e1eaa4c5fbf773b94b70cddc85 Reviewed-on: https://chromium-review.googlesource.com/861302 Reviewed-by: Fadi Meawad <[email protected]> Reviewed-by: Yang Guo <[email protected]> Commit-Queue: Ali Ijaz Sheikh <[email protected]> Cr-Commit-Position: refs/heads/master@{nodejs#50549} Refs: v8/v8@c3bb73f Refs: nodejs#17349 PR-URL: nodejs#18196 Refs: nodejs#18360 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Andreas Madsen <[email protected]>
trace_events
has an internal clock, this makes it very difficult to correlate the data with other external data. I would suggest that we emit a Clock Sync Event on startup for synchronizing withDate.now()
andprocess.hrtime()
./cc @nodejs/v8 - as we currently lack a
trace_events
specialist.The text was updated successfully, but these errors were encountered: