Skip to content

Trace document registry operations #47785

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

Merged
merged 1 commit into from
Feb 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/services/documentRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,27 @@ namespace ts {
scriptKind?: ScriptKind): SourceFile {
scriptKind = ensureScriptKind(fileName, scriptKind);
const scriptTarget = scriptKind === ScriptKind.JSON ? ScriptTarget.JSON : getEmitScriptTarget(compilationSettings);

const oldBucketCount = buckets.size;
const bucket = getOrUpdate(buckets, key, () => new Map());
if (tracing) {
if (buckets.size > oldBucketCount) {
// It is interesting, but not definitively problematic if a build requires multiple document registry buckets -
// perhaps they are for two projects that don't have any overlap.
// Bonus: these events can help us interpret the more interesting event below.
tracing.instant(tracing.Phase.Session, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key });
}

// It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations.
// If this occurs unexpectedly, the fix is likely to synchronize the project settings.
// Skip .d.ts files to reduce noise (should also cover most of node_modules).
const otherBucketKey = !fileExtensionIs(path, Extension.Dts) &&
Copy link
Member Author

Choose a reason for hiding this comment

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

I could be persuaded that this is too chatty, but it has the advantage of indicating the proportion of overlap (e.g. a single-file overlap is likely uninteresting).

forEachEntry(buckets, (bucket, bucketKey) => bucketKey !== key && bucket.has(path) && bucketKey);
if (otherBucketKey) {
tracing.instant(tracing.Phase.Session, "documentRegistryBucketOverlap", { path, key1: otherBucketKey, key2: key });
}
}

const bucketEntry = bucket.get(path);
let entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind);
if (!entry && externalCache) {
Expand Down