Skip to content

Commit ab45c0e

Browse files
committed
Expand working group and repo to all diagnostics.
Add additional top level to repo with subfolders for diagnostic domains. Add initial README.md for each domain. Add some initial docs and samples for domains beyond tracing. Move and minor cleanup of AsyncWrap docs and background info on TRACE_EVENT.
1 parent d3a41e9 commit ab45c0e

File tree

14 files changed

+176
-72
lines changed

14 files changed

+176
-72
lines changed

README.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
1-
# tracing-wg
1+
# Diagnostics Working Group
2+
The goal of this WG is to ensure Node provides a set of comprehensive, documented, extensible diagnostic protocols, formats, and APIs to enable tool vendors to provide reliable diagnostic tools for Node.
23

3-
Tracing Working Group
4+
Work is divided into several domains:
5+
- [Tracing](./tracing)
6+
- [Profiling](./profiling)
7+
- [Heap and Memory Analysis](./heap-memory)
8+
- [Step Debugging](./debugging)
49

5-
# Members
10+
Background, reference documentation, samples, and discussion for each domain is contained within its folder.
611

12+
Work needed includes:
13+
- Collect, understand, and document existing diagnostic capabilities and entry-points throughout Node, V8, and other components.
14+
- Collect and document projects and products providing diagnostics for Node with brief description of their technical architecture and sponsoring organizations.
15+
- Identify opportunities and gaps, then propose and implement solutions.
16+
17+
### Logistics
18+
- Monthly Meetings
19+
- Biannual F2F
20+
21+
### Members
722
* @bnoordhuis
823
* @sam-github
924
* @othiym23
@@ -28,3 +43,5 @@ Tracing Working Group
2843
* @matthewloring
2944
* @pmuellr
3045
* @jeffolfert
46+
* @joshgav
47+

debugging/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## Debugging API
2+
- [Chrome Debugging Protocol](https://chromedevtools.github.io/debugger-protocol-viewer/)
3+
- [V8 Debugging Protocol](https://github.com/v8/v8/wiki/Debugging-Protocol)
4+
5+
Node currently relies on V8's internal Debug API and associated commands and events. The Debug API is published at [v8/include/v8-debug.h](https://github.com/v8/v8/blob/master/include/v8-debug.h), and the message protocol is documented in prose in [the V8 wiki](https://github.com/v8/v8/wiki/Debugging-Protocol) and in code in [v8/src/debug/debug.js#L2341-2372](https://github.com/v8/v8/blob/master/src/debug/debug.js#L2341-L2372).
6+
7+
Node also provides an agent [node/src/debug-agent.h](https://github.com/blob/master/src/debug-agent.h) which relays requests, responses, and events through a TCP socket, and a command-line debugger [node/lib/_debugger.js](https://github.com/blob/master/lib/_debugger.js).
8+
9+
The Chrome/V8 team has deprecated the internal V8 API and command set and proposed replacing it with a subset of the Chrome Debugging Protocol (CrDP), see https://github.com/nodejs/node/issues/2546. CrDP is documented at [https://chromedevtools.github.io/debugger-protocol-viewer/]() and the backing GitHub repo.
10+
11+
The [cyrus-and/chrome-remote-interface](https://github.com/cyrus-and/chrome-remote-interface) library provides a JS proxy for CrDP.
12+
13+
## Step Debugging Tools
14+
Name | Sponsor
15+
-----|--------
16+
[node-inspector][] | StrongLoop
17+
[JetBrains WebStorm][] | JetBrains
18+
[Visual Studio Code][] | Microsoft
19+
[Node CLI Debugger][] | Node Foundation
20+
[Chrome DevTools][] | Google
21+
[Theseus][] | Adobe Research
22+
23+
[node-inspector]: https://github.com/node-inspector/node-inspector
24+
[JetBrains WebStorm]: https://www.jetbrains.com/help/webstorm/2016.1/running-and-debugging-node-js.html
25+
[Visual Studio Code]: https://github.com/Microsoft/vscode
26+
[Node CLI Debugger]: https://nodejs.org/api/debugger.html
27+
[Chrome DevTools]: https://github.com/ChromeDevTools/devtools-frontend
28+
[Theseus]: https://github.com/adobe-research/theseus
29+

docs/README.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

docs/perf-events/README.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/platform-tracing/README.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

heap-memory/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## Heap and Memory Analysis
2+
The [nodejs/post-mortem](https://github.com/nodejs/post-mortem) WG is responsible for this domain.
3+
4+
### Heap Analysis
5+
- [mdb_v8](https://github.com/joyent/mdb_v8)
6+
- [node-heapdump](https://github.com/bnoordhuis/node-heapdump)
7+
- [llnode](https://github.com/indutny/llnode)
8+
- [IBM IDDE](https://www.ibm.com/developerworks/java/jdk/tools/idde/)
9+
- [Snapshot Utils](https://github.com/bmeck/snapshot-utils)
10+

profiling/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Profiling for Node
2+
- CPU Profiling
3+
- V8 CPU Profiler: [v8/include/v8-profiler.h](https://github.com/v8/blob/master/include/v8-profiler.h)
4+
- Accessible globally through `--prof` runtime flag, basic processing and display through `--prof-processor` runtime flag
5+
- Intel vTune profiler. Accessible through `--enable-vtune-profiling` compile-time flag.
6+
7+
- Heap Profiling
8+
- V8 Heap Profiler: [v8/include/v8-profiler.h](https://github.com/v8/blob/master/include/v8-profiler.h)
9+
- Heap memory usage stats are available through built-in 'v8' module.
10+
11+
Name | Sponsor
12+
-----|--------
13+
[v8-profiler][] | StrongLoop
14+
[Chrome DevTools][] | Google
15+
16+
[v8-profiler]: https://github.com/node-inspector/v8-profiler
17+
[Chrome DevTools]: https://github.com/ChromeDevTools/devtools-frontend
18+
19+
### Stack Analysis
20+
- [0x](https://github.com/davidmarkclements/0x)
21+
- [StackVis](https://github.com/joyent/node-stackvis)
22+
23+
## Docs
24+
[guides/simple-profiling](https://nodejs.org/en/docs/guides/simple-profiling/)
25+
[paulirish/automated-chrome-profiling](https://github.com/paulirish/automated-chrome-profiling)
26+
File renamed without changes.

tracing/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Tracing
2+
- [AsyncWrap](./AsyncWrap/README.md) - Most native objects are represented indirectly by the [AsyncWrap class](https://github.com/nodejs/node/blob/master/src/async-wrap.h), so hooks have been added to that class to trace lifecycle (init/destroy) and callback activity (pre/post) related to these objects.
3+
4+
- [OS Tracing](./os-tracing/README.md) - LTTng (Linux), SystemTap (Linux), DTrace (OSX), ETW (Windows)
5+
6+
- [VM Tracing](./vm-tracing/README.md) - Tracing native to JS VMs, such as V8's TRACE_EVENT.
7+

tracing/os-tracing/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## OS Tracing
2+
3+
* [DTrace](http://dtrace.org/)
4+
Available on IllumOS, Solaris, Mac
5+
6+
- The [DTrace blog](http://dtrace.org/blogs/blog/category/node-js/) has some articles on using DTrace with Node.js
7+
8+
* [LTTng](http://lttng.org/)
9+
Linux only.
10+
11+
- [Tracing Node on Linux with LTTNG](http://nearform.github.io/tracing-node-lttng-nodejsdublin/)
12+
- [thekemkid/magic-tracing](https://github.com/thekemkid/magic-tracing) is an example of a Node.js application which implements LTTng tracepoints. A demo is available [here](https://asciicinema.org/a/16785).
13+
14+
* [ETW](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363668.aspx)
15+
Windows only.
16+
17+
- Some information was provided by Bill Ticehurst (@billti) in [issue #10](https://github.com/nodejs/tracing-wg/issues/10#issuecomment-137145822) about how he integrated ETW into Node.js for Windows
18+
19+
* [Perf](https://perf.wiki.kernel.org/)
20+
Linux only.
21+
22+
- Can be enabled with `--perf_basic_prof` v8 run-time flag.
23+
24+
* [SystemTap](https://sourceware.org/systemtap/)
25+
Linux only.
26+

docs/v8-tracing/README.md renamed to tracing/vm-tracing/README.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1-
Node.js tracing - native v8 tracing
2-
================================================================================
1+
## VM Native Tracing
2+
- See [v8-tracing.md](./v8-tracing.md) for technical details and crude implementation.
33

4-
Google is restructuring the tracing in V8 to accommodate restructuring of
5-
tracing in Chrome.
4+
- All trace events are streamed through the same native component, which can in turn publish as appropriate to its subscribers.
5+
- Ideally should be possible to subscribe and receive events in JavaScript too.
6+
- Requires implementation in Node.js, could learn from Chromium's implementation.
7+
- For maximum utility, we should add trace events to Node's operations, especially async ones.
8+
- Possible to handle other trace sources, such as OS (LTTng, ETW) alongside V8 trace source, since they all are event streams.
69

7-
----
10+
## Resources
11+
- [google/trace-viewer](https://github.com/google/trace-viewer) - `chrome://tracing` UI.
12+
- [chromium/src/base/trace_event/](https://code.google.com/p/chromium/codesearch#chromium/src/base/trace_event/)
13+
- [Chromium Speed-Infra](https://www.chromium.org/developers/speed-infra)
14+
- [Chromium Telemetry](https://catapult.gsrc.io/telemetry)
15+
- [Trace Platform Explainer](https://docs.google.com/a/chromium.org/document/d/1l0N1B4L4D94andL1BY39Rs_yXU8ktJBrKbt9EvOb-Oc/edit)
16+
- [Implementations for V8, D8, Chromium](https://docs.google.com/a/chromium.org/document/d/1_4LAnInOB8tM_DLjptWiszRwa4qwiSsDzMkO4tU-Qes/edit#)
17+
- [Trace Event Format](https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/edit)
18+
19+
### Background
820

9-
Some older-ish comments from @natduca in
10-
[nodejs/node issue #671](https://github.com/nodejs/node/issues/671#issuecomment-73191538):
21+
@natduca in [nodejs/node#671_comment](https://github.com/nodejs/node/issues/671#issuecomment-73191538):
1122

1223
I thought I'd provide some notes on the direction we're taking in chrome and indirectly v8 around tracing & stack sampling. Since we both intersect at v8 and do run into some of the same "guhh i need a tracing api but its gotta be low overhead," I hope there's some useful context!
1324

@@ -37,8 +48,7 @@ Anyway, thats a lotta words. Hope it makes sense! This was all designed with cli
3748

3849
----
3950

40-
@ofrobots added some additional detail in
41-
[issue #21](https://github.com/nodejs/tracing-wg/issues/21#issuecomment-143891637):
51+
@ofrobots in [nodejs/tracing-wg#21_comment](https://github.com/nodejs/tracing-wg/issues/21#issuecomment-143891637):
4252

4353
Here are the main components, as per my understanding:
4454

@@ -54,6 +64,3 @@ Basically this trace-event buffer becomes the 'single pipe' through all trace-ev
5464

5565
Once the above linked CL lands, traces being gathered in V8 will show up there. Node.js can start putting its own traces into the same pipe. I would imagine we would also need an API in Node.js to be exposed to JavaScript to allow JS code to start sending the trace events.
5666

57-
----
58-
59-
If you have more info to provide, please send us a pull request!

tracing/vm-tracing/v8-tracing.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## V8/Chromium Tracing
2+
Generic macro definitions intended to be shared by many projects are in `trace_event_common.h`.
3+
Source of truth for `trace_event_common.h` is in `chromium:src/base/trace_event/trace_event_common.h`.
4+
This file is in Chromium but not in V8. @ofrobots copied it into `nodejs:deps/v8`. Perhaps it should be moved to `nodejs:deps/v8/include` or `nodejs:deps/v8/src/trace_event`.
5+
6+
Implementation-specific ("INTERNAL_*") macro definitions are in `v8:src/trace_event.h` and `chromium:src/base/trace_event.h`.
7+
Chromium: `trace_event.h` macros utilize `v8::base::TraceLog::AddTraceEvent` to write traces.
8+
V8: `trace_event.h` macros utilize `v8::Platform::AddTraceEvent` to write traces.
9+
Node uses `DefaultPlatform` from `v8:src/libplatform/default-platform.h` which currently simply returns 0.
10+
A simplistic implementation which logs all trace events to stdout illustrates the basics:
11+
12+
```
13+
// from v8:src/libplatform/default-platform.cc
14+
// add `#include <iostream>` to includes
15+
16+
uint64_t DefaultPlatform::AddTraceEvent(
17+
char phase, const uint8_t* category_enabled_flag, const char* name,
18+
/* const char* scope, */ uint64_t id, uint64_t bind_id, int num_args,
19+
const char** arg_names, const uint8_t* arg_types,
20+
const uint64_t* arg_values, unsigned int flags) {
21+
22+
time_t timestamp = std::time(nullptr);
23+
24+
std::cout << "phase: " << phase << std::endl;
25+
std::cout << "category_enabled_flag: " << category_enabled_flag << std::endl;
26+
std::cout << "name: " << name << std::endl;
27+
std::cout << "id: " << id << std::endl;
28+
std::cout << "epoch_timestamp: " << timestamp << std::endl;
29+
std::cout << "human_timestamp: " << std::asctime(std::localtime(&timestamp)) << std::endl;
30+
31+
return 0;
32+
}
33+
34+
const uint8_t* DefaultPlatform::GetCategoryGroupEnabled(const char* name) {
35+
static uint8_t yes = CategoryGroupEnabledFlags::kEnabledForRecording_CategoryGroupEnabledFlags |
36+
CategoryGroupEnabledFlags::kEnabledForEventCallback_CategoryGroupEnabledFlags;
37+
return &yes;
38+
}
39+
```

0 commit comments

Comments
 (0)