-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Tracing work #40634
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
Tracing work #40634
Conversation
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.
Minor suggestions. Overall, looks good.
c336cd7
to
32d9923
Compare
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.
Still LGTM
src/compiler/tracing.ts
Outdated
performance.mark("beginTracing"); | ||
fs.writeSync(traceFd, `{"pid":1,"tid":1,"ph":"i","cat":"${phase}","ts":${1000 * timestamp()},"name":"${name}","s":"g","args":{ "ts": ${JSON.stringify(args)} }},\n`); | ||
fs.writeSync(traceFd, `,{"pid":1,"tid":1,"ph":"${eventType}","cat":"${phase}","ts":${time},"name":"${name}"`); |
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.
Why did this comma need to move? If it has to be this way, maybe we could move the \n
too so that the comma is still at EOL?
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.
The resulting dump will look like:
,{...}
,{...}
,{...}
,{...}
]
so this makes it possible to have decent looking output and not worry about aborting or special casing the last value. I normally dislike this style too, but I want to avoid special cases to avoid as much runtime overhead as possible, and avoid complicating the code for something that is rarely used (looking at the dump text directly).
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.
Right, but what if it was ,\n{"pid"
? Then the comma still wouldn't be inserted without a following item, but it would appear on the right line.
03a2606
to
eb3f357
Compare
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.
Minor comments.
src/compiler/tracing.ts
Outdated
performance.mark("beginTracing"); | ||
fs.writeSync(traceFd, `{"pid":1,"tid":1,"ph":"i","cat":"${phase}","ts":${1000 * timestamp()},"name":"${name}","s":"g","args":{ "ts": ${JSON.stringify(args)} }},\n`); | ||
fs.writeSync(traceFd, `,{"pid":1,"tid":1,"ph":"${eventType}","cat":"${phase}","ts":${time},"name":"${name}"`); |
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.
Right, but what if it was ,\n{"pid"
? Then the comma still wouldn't be inserted without a following item, but it would appear on the right line.
eb3f357
to
5dbf176
Compare
@amcasey: I don't know why gh won't let me reply to the line comment -- the thing that I dislike is to have the implicit invariant that we're at the EOL after output, since that leads more easily to a mess later on. But anyway, that's not nearly a strong enough of an opinion, so I just changed it... |
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.
LGTM, except for one potentially confusing typo. Thanks!
* Fix: `E` events need to have the same information that is on the corresponding `B` events. (Superseded below.) * Use `I` (not `i`) for instant events, so they show in devtools too. (Though they don't go through the flame chart as they do in `about://tracing`, so they're not nearly as useful.) * Abstract the code that writes the records in a single `writeEvent` local function. * Make `args` optional, and default to `undefined` (which will not add them) at all. * Drop the `{ "ts": ... }` wrapper around the `args`, after verifying that having arguments with names like `begin`, `end`, `pos`, `id` doesn't interfere with either UIs. * Add `tracing.push`/`tracing.pop` for complete events, change a few `.begin`/`.end` to use these. (The caveat is that until there's an exit handler to dump unterminated events, these won't show in the dump. When that's done the push/pop variant can be used everywhere.) * Add meta lines to name the process and the thread, and a line that avoids the warning when opening in devtools.
5dbf176
to
f1f4a3c
Compare
E
events need to have the same information that is on thecorresponding
B
events.Use
I
(noti
) for instant events, so they show in devtoolstoo. (Though they don't go through the flame chart as they do in
about://tracing
, so they're not nearly as useful.)Abstract the code that writes the records in a single
spitEvent
local function.
Make
args
optional, and default toundefined
(which will not addthem) at all.
Drop the
{ "ts": ... }
wrapper around theargs
, after verifyingthat having arguments with names like
begin
,end
,pos
,id
doesn't interfere with either UIs.
Add
tracing.push
/tracing.pop
for complete events, change a few.begin
/.end
to use these. (The caveat is that until there's an exithandler to dump unterminated events, these won't show in the dump. When
that's done the push/pop variant can be used everywhere.)
Add meta lines to name the process and the thread, and a line that
avoids the warning when opening in devtools.