perf(shared): skip duplicate PATH entries and per-probe tracing #9618
Mergedjadeva(GitHub profile, opens in a new tab)merged 3 commits into
main fromrefs/pull/9618/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- packages/shared/src/shell.ts lines 624 to 627OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -606,8 +610,18 @@606610 }607611612+ // A Windows PATH routinely names the same directory more than once: the user613+ // and machine values overlap, and `resolveKnownWindowsCliDirs` appends614+ // entries that are frequently already present. Visiting a directory twice615+ // inside one walk cannot produce a different answer, so drop the repeats616+ // before spending syscalls on them. `mergePathValues` above already617+ // de-duplicates this way; the scan simply never did.608618 const pathEntries: string[] = [];619+ const seenPathEntries = new Set<string>();609620 for (const entry of pathValue.split(pathDelimiterForPlatform(platform))) {610621 const pathEntry = stripWrappingQuotes(entry.trim());611- if (pathEntry.length > 0) {612- pathEntries.push(pathEntry);613- }622+ if (pathEntry.length === 0) continue;623+624+ const normalizedPathEntry = normalizePathEntryForComparison(pathEntry, platform);625+ if (seenPathEntries.has(normalizedPathEntry)) continue;626+627+ seenPathEntries.add(normalizedPathEntry);packages/shared/src/shell.ts lines 610 to 618Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -608,7 +612,18 @@612+ // A Windows PATH routinely names the same directory more than once: the user613+ // and machine values overlap, and `resolveKnownWindowsCliDirs` appends614+ // entries that are frequently already present. Visiting a directory twice615+ // inside one walk cannot produce a different answer, so drop the repeats616+ // before spending syscalls on them. `mergePathValues` above already617+ // de-duplicates this way; the scan simply never did.608618 const pathEntries: string[] = [];619+ const seenPathEntries = new Set<string>();609620 for (const entry of pathValue.split(pathDelimiterForPlatform(platform))) {610621 const pathEntry = stripWrappingQuotes(entry.trim());611- if (pathEntry.length > 0) {612- pathEntries.push(pathEntry);613- }622+ if (pathEntry.length === 0) continue;623+624+ const normalizedPathEntry = normalizePathEntryForComparison(pathEntry, platform);625+ if (seenPathEntries.has(normalizedPathEntry)) continue;626+627+ seenPathEntries.add(normalizedPathEntry);628+ pathEntries.push(pathEntry);614629 }
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
juliusmarminge changed the title
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge approved these changes
juliusmarminge merged thisc3cacea
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed