-
Notifications
You must be signed in to change notification settings - Fork 756
Description
Description
When running tsgo --build on a project with source maps and declaration maps disabled, a significant amount of CPU and memory is spent on what seemingly should be unused source map-related functions.
tsgo setup
tsgo version: 7.0.0-dev.20251204.1
Details
After migrating our monorepo to tsgo with a significant local performance improvement, I went to test the new setup in CI and discovered worse performance than typescript@5.8.3 on a CI machine with 4 CPU cores and 16gb memory. I ran tsgo with profiling enabled (profiles attached below) and noticed (with the help of Claude) that source map emission accounted for ~60% of cumulative CPU time during compilation despite source maps and declaration maps both being disabled during the build:
0 0% 90.69% 126.39s 29.24% github.com/microsoft/typescript-go/internal/printer.(*Printer).emitSourceMapsAfterNode
0 0% 90.69% 125.28s 28.99% github.com/microsoft/typescript-go/internal/printer.(*Printer).emitSourceMapsBeforeNode
The memory profile looks much less interesting, I suspect the ~18GiB of memory consumed by our project is just related to having ~1mm LOC and heavy use of intersection types, but I'm surprised to see the source map printer consuming the majority of CPU time while all maps are disabled.