Extension activation telemetry's `codeLoadingTime` is misleading
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
Does this issue occur when all extensions are disabled?: N/A
- VS Code Version: 1.134.0
- OS Version: Windows 11
The `codeLoadingTime` reported to telemetry for extension activation time can be misleading--it is essentially a wall-clock time measurement around module load. For CJS extensions, this is a good approximation--since `require()` will be synchronous--but for ESM extensions, this breaks down. With ESM, if any other extensions are activating or working hard at the same time (which is highly likely especially at startup), then any work they are doing could be counted against your extension's code loading time, as their async work is interleaved with the async work of loading your extension code.
The bottom line is that ESM extension code loading time could be severely overstated in telemetry.
Having a truly accurate measurement would probably involve complex `async_hooks` / `AsyncLocalStorage` stuff, but a cheap approximation could be achieved just by including, e.g., some measures for event loop utilization/delay to estimate the contention, along with telemetry readers focusing on code loading measurements without much contention--so they can get a more "fair" understanding.
Contributor guide
Assessment
This issue has not been assessed yet.