Skip to content

Speed up sourcemap lookups by checking existence of .map files#1780

Merged
connor4312 merged 7 commits intomicrosoft:mainfrom
sunilsurana:main
Aug 11, 2023
Merged

Speed up sourcemap lookups by checking existence of .map files#1780
connor4312 merged 7 commits intomicrosoft:mainfrom
sunilsurana:main

Conversation

@sunilsurana
Copy link
Contributor

Problem
Debugging experience is slow in large monorepos, since all the files are read to check location of sourcemap file

PR fix
Check if .map file exists for compiled file we don't need to read file to find location of sourcemap location.

Possible issue
If there is a js file and it has .map file which is not a sourcemap file with same js file name, it can lead to issue.
This however should be rare edge case.

fileContents = await readfile(compiledPath);
let sourceMapUrl;
const possibleSourceMapURL = `${compiledPath}.map`;
if (await fsUtils.exists(possibleSourceMapURL)) {
Copy link
Member

@connor4312 connor4312 Aug 7, 2023

Choose a reason for hiding this comment

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

Rather than making a separate exists call here, you can pass the siblings elements of the directory to the fileProcessor function.

It's called by readSomething which is called for the root entry (no siblings) and in handleDirectoryEntry. In the latter case, it's called reading either from the cache tree (where Object.keys(cache.children) are siblings) or from the filesystem (where files are siblings)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. I'm not fully sure thou if you meant the same changes

@connor4312 connor4312 enabled auto-merge (squash) August 10, 2023 22:43
@connor4312 connor4312 disabled auto-merge August 10, 2023 22:43
@connor4312 connor4312 enabled auto-merge (squash) August 10, 2023 22:43
@connor4312 connor4312 merged commit e82e8f7 into microsoft:main Aug 11, 2023
@connor4312 connor4312 added this to the August 2023 milestone Aug 30, 2023
@gregvanl gregvanl changed the title Speed up sourcemap lookups by checking existance of .map files Speed up sourcemap lookups by checking existence of .map files Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants