-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Optimize source mapping into external source map sources #40055
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
Optimize source mapping into external source map sources #40055
Conversation
@@ -51,6 +52,10 @@ namespace ts { | |||
|
|||
function addSource(fileName: string) { | |||
enter(); | |||
const sourceIndexByFileName = fileNameToSourceIndexMap.get(fileName); |
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.
Implementation note: this could alternatively be done without a full cache, using just a single MRU fileName/sourceIndex. That does however require that the second call to setSourceMapSource
in emitSourcePos
has to take an additional parameter to not even call addSource
(which is safe as reverting to the prior source map source is known to have been added) as otherwise 2 MRU items are needed:
TypeScript/src/compiler/emitter.ts
Lines 5290 to 5300 in a7d8011
function emitSourcePos(source: SourceMapSource, pos: number) { | |
if (source !== sourceMapSource) { | |
const savedSourceMapSource = sourceMapSource; | |
setSourceMapSource(source); | |
emitPos(pos); | |
setSourceMapSource(savedSourceMapSource); | |
} | |
else { | |
emitPos(pos); | |
} | |
} |
This alternative would also mitigate the issue (I verified that) as it's typical for a single external source map source to be applied on nodes without interference from nodes that have a different external source map source, so a single MRU cache entry is sufficient.
afb77aa
to
4b4a156
Compare
Shucks, we really should have run a perf test on this. @typescript-bot perf test this |
Heya @DanielRosenwasser, I've started to run the perf test suite on this PR at 4b4a156. You can monitor the build here. |
well duh, that'll do nothing now. |
)" This reverts commit 1e84ffc.
Fixes #40054
Timings
emitSourcePos
setSourceMapSource