Skip to content

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

Merged
merged 1 commit into from
Oct 21, 2020
Merged

Tracing work #40634

merged 1 commit into from
Oct 21, 2020

Conversation

elibarzilay
Copy link
Contributor

  • E events need to have the same information that is on the
    corresponding B events.

  • 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 spitEvent
    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.

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Sep 18, 2020
@elibarzilay elibarzilay marked this pull request as draft September 18, 2020 17:11
Copy link
Member

@amcasey amcasey left a 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.

@elibarzilay elibarzilay force-pushed the tracing-work branch 2 times, most recently from c336cd7 to 32d9923 Compare October 15, 2020 23:03
@elibarzilay elibarzilay marked this pull request as ready for review October 15, 2020 23:04
Copy link
Member

@amcasey amcasey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still LGTM

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}"`);
Copy link
Member

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?

Copy link
Contributor Author

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).

Copy link
Member

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.

@elibarzilay elibarzilay force-pushed the tracing-work branch 2 times, most recently from 03a2606 to eb3f357 Compare October 20, 2020 21:22
Copy link
Member

@amcasey amcasey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments.

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}"`);
Copy link
Member

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.

@elibarzilay
Copy link
Contributor Author

@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...

Copy link
Member

@amcasey amcasey left a 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.
@elibarzilay elibarzilay merged commit fe7ec1e into microsoft:master Oct 21, 2020
@elibarzilay elibarzilay deleted the tracing-work branch October 21, 2020 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants