Make `tracing` either `undefined` or the same namespace as before.
Switching all calls to `tracing?.___` means that there is no cost for
a call or the arguments when tracing is not used. Comparing two runs
without tracing (27 runs, drop 5+5, avg rest) I get:
master:
42.59s user 1.00s system 165% cpu 26.372 total
changed:
42.01s user 0.982 system 165% cpu 26.039 total
(Makes it all private, so no api changes.)
* Use stricter types for tracing event arguments
In local development, I've routinely passed the wrong local and ended up
having JSON.stringify throw.
* Make the type recursive
Courtesy of @rbuckton
* Fix lint error
* Add tracing support to tsserver
Read the `TSS_TRACE` environment variable to determine which directory
trace files should be written to.
Notable changes from tsc tracing:
1) Drop all tracepoints that depend on type IDs
2) Write output to trace.PID.json
3) New, server-specific events (request/response, cancellation, etc)
* Drop try-finally blocks that aren't strictly necessary
* Fix lint error
* Trace background work (for diagnostics)
* Move try-finally blocks into session so tsc doesn't use them
* Add missing try-finally
* Use consistent capitalization
* Inline canPop call where underlying variable is available
* Clarify comments
* Include PID in build-mode file names
* Introduce more efficient popAll function
* Trace throwIfCancellationRequested rather than isCancellationRequested
* Remove unnecessary try-finally blocks
* Add a command-line argument for consistency with logging
* Fix rebase issues
* Address PR feedback
* Rename completionEvents to eventStack
* Drop assertStackEmpty as hard-to-maintain and marginally valuable
* Rename stepCancellation to stepCanceledEarly
* Rename stepEarlyCancellation to stepCanceled and use flag instead
* Check correct variable on exit
Storing the arguments on the stack will make it possible to forego
try-finally blocks when we start tracing in server scenarios, which have
to handle cancellation.
* 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.