refine "workspace.stats.metadata" (#214000)

This commit is contained in:
Johannes Rieken 2024-05-31 14:48:52 +02:00 committed by GitHub
parent f444002632
commit 95b4682f72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 5 deletions

View file

@ -79,8 +79,9 @@ export interface WorkspaceStats {
configFiles: WorkspaceStatItem[];
fileCount: number;
maxFilesReached: boolean;
totalScanTime: number;
launchConfigFiles: WorkspaceStatItem[];
totalScanTime: number;
totalReaddirCount: number;
}
export interface PerformanceInfo {

View file

@ -61,11 +61,13 @@ export async function collectWorkspaceStats(folder: string, filter: string[]): P
const MAX_FILES = 20000;
function collect(root: string, dir: string, filter: string[], token: { count: number; maxReached: boolean }): Promise<void> {
function collect(root: string, dir: string, filter: string[], token: { count: number; maxReached: boolean; readdirCount: number }): Promise<void> {
const relativePath = dir.substring(root.length + 1);
return Promises.withAsyncBody(async resolve => {
let files: IDirent[];
token.readdirCount++;
try {
files = await pfs.readdir(dir, { withFileTypes: true });
} catch (error) {
@ -131,7 +133,7 @@ export async function collectWorkspaceStats(folder: string, filter: string[]): P
}
const statsPromise = Promises.withAsyncBody<WorkspaceStats>(async (resolve) => {
const token: { count: number; maxReached: boolean } = { count: 0, maxReached: false };
const token: { count: number; maxReached: boolean; readdirCount: number } = { count: 0, maxReached: false, readdirCount: 0 };
const sw = new StopWatch(true);
await collect(folder, folder, filter, token);
const launchConfigs = await collectLaunchConfigs(folder);
@ -140,8 +142,9 @@ export async function collectWorkspaceStats(folder: string, filter: string[]): P
fileTypes: asSortedItems(fileTypes),
fileCount: token.count,
maxFilesReached: token.maxReached,
launchConfigFiles: launchConfigs,
totalScanTime: sw.elapsed(),
launchConfigFiles: launchConfigs
totalReaddirCount: token.readdirCount
});
});
@ -578,13 +581,15 @@ export class DiagnosticsService implements IDiagnosticsService {
duration: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'How did it take to make workspace stats' };
reachedLimit: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'Did making workspace stats reach its limits' };
fileCount: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'How many files did workspace stats discover' };
readdirCount: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'How many readdir call were needed' };
};
type WorkspaceStatsMetadata = {
duration: number;
reachedLimit: boolean;
fileCount: number;
readdirCount: number;
};
this.telemetryService.publicLog2<WorkspaceStatsMetadata, WorkspaceStatsMetadataClassification>('workspace.stats.metadata', { duration: stats.totalScanTime, reachedLimit: stats.maxFilesReached, fileCount: stats.fileCount });
this.telemetryService.publicLog2<WorkspaceStatsMetadata, WorkspaceStatsMetadataClassification>('workspace.stats.metadata', { duration: stats.totalScanTime, reachedLimit: stats.maxFilesReached, fileCount: stats.fileCount, readdirCount: stats.totalReaddirCount });
} catch {
// Report nothing if collecting metadata fails.
}