Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { statSync } from "fs";
import path from "path";
import { ViewColumn } from "vscode";
import type { CodeQLCliServer } from "../codeql-cli/cli";
Expand All @@ -12,6 +13,7 @@ import { showAndLogExceptionWithTelemetry } from "../common/logging";
import { extLogger } from "../common/logging/vscode";
import type { WebviewPanelConfig } from "../common/vscode/abstract-webview";
import { AbstractWebview } from "../common/vscode/abstract-webview";
import { withProgress } from "../common/vscode/progress";
import { telemetryListener } from "../common/vscode/telemetry";
import type { ResultsView } from "../local-queries";
import { scanLog } from "../log-insights/log-scanner";
Expand Down Expand Up @@ -54,12 +56,22 @@ export class ComparePerformanceView extends AbstractWebview<

await this.waitForPanelLoaded();

// TODO: try processing in (async) parallel once readJsonl is streaming
const fromPerf = await scanLog(
fromJsonLog,
new PerformanceOverviewScanner(),
);
const toPerf = await scanLog(toJsonLog, new PerformanceOverviewScanner());
function scanLogWithProgress(log: string, logDescription: string) {
const bytes = statSync(log).size;
return withProgress(
async (progress) =>
scanLog(log, new PerformanceOverviewScanner(), progress),

{
title: `Scanning evaluator log ${logDescription} (${(bytes / 1024 / 1024).toFixed(1)} MB)`,
},
);
}

const [fromPerf, toPerf] = await Promise.all([
scanLogWithProgress(fromJsonLog, "1/2"),
scanLogWithProgress(toJsonLog, "2/2"),
]);

// TODO: filter out irrelevant common predicates before transfer?

Expand Down
14 changes: 11 additions & 3 deletions extensions/ql-vscode/src/log-insights/log-scanner.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { SummaryEvent } from "./log-summary";
import { readJsonlFile } from "../common/jsonl-reader";
import type { Disposable } from "../common/disposable-object";
import { readJsonlFile } from "../common/jsonl-reader";
import type { ProgressCallback } from "../common/vscode/progress";
import type { SummaryEvent } from "./log-summary";

/**
* Callback interface used to report diagnostics from a log scanner.
Expand Down Expand Up @@ -114,15 +115,22 @@ export class EvaluationLogScannerSet {
}

/**
* Scan the evaluator summary log using the given scanner. For conveience, returns the scanner.
* Scan the evaluator summary log using the given scanner. For convenience, returns the scanner.
*
* @param jsonSummaryLocation The file path of the JSON summary log.
* @param scanner The scanner to process events from the log
*/
export async function scanLog<T extends EvaluationLogScanner>(
jsonSummaryLocation: string,
scanner: T,
progress?: ProgressCallback,
): Promise<T> {
progress?.({
// XXX all scans have step 1 - the backing progress tracker allows increments instead of steps - but for now we are happy with a tiny UI that says what is happening
message: `Scanning ...`,
step: 1,
maxStep: 2,
});
await readJsonlFile<SummaryEvent>(jsonSummaryLocation, async (obj) => {
scanner.onEvent(obj);
});
Expand Down
Loading