Skip to content

Commit d0456db

Browse files
committed
feat: parallel log scanning
1 parent 635cde0 commit d0456db

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

extensions/ql-vscode/src/compare-performance/compare-performance-view.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { showAndLogExceptionWithTelemetry } from "../common/logging";
1212
import { extLogger } from "../common/logging/vscode";
1313
import type { WebviewPanelConfig } from "../common/vscode/abstract-webview";
1414
import { AbstractWebview } from "../common/vscode/abstract-webview";
15+
import { withProgress } from "../common/vscode/progress";
1516
import { telemetryListener } from "../common/vscode/telemetry";
1617
import type { ResultsView } from "../local-queries";
1718
import { scanLog } from "../log-insights/log-scanner";
@@ -54,12 +55,24 @@ export class ComparePerformanceView extends AbstractWebview<
5455

5556
await this.waitForPanelLoaded();
5657

57-
// TODO: try processing in (async) parallel once readJsonl is streaming
58-
const fromPerf = await scanLog(
59-
fromJsonLog,
60-
new PerformanceOverviewScanner(),
58+
const { fromPerf, toPerf } = await withProgress(
59+
async (progress) => {
60+
const fromPerf = scanLog(
61+
fromJsonLog,
62+
new PerformanceOverviewScanner(),
63+
progress,
64+
);
65+
const toPerf = scanLog(
66+
toJsonLog,
67+
new PerformanceOverviewScanner(),
68+
progress,
69+
);
70+
return { fromPerf: await fromPerf, toPerf: await toPerf };
71+
},
72+
{
73+
title: "Parsing performance logs",
74+
},
6175
);
62-
const toPerf = await scanLog(toJsonLog, new PerformanceOverviewScanner());
6376

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

extensions/ql-vscode/src/log-insights/log-scanner.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import type { SummaryEvent } from "./log-summary";
2-
import { readJsonlFile } from "../common/jsonl-reader";
31
import type { Disposable } from "../common/disposable-object";
2+
import { readJsonlFile } from "../common/jsonl-reader";
3+
import type { ProgressCallback } from "../common/vscode/progress";
4+
import type { SummaryEvent } from "./log-summary";
45

56
/**
67
* Callback interface used to report diagnostics from a log scanner.
@@ -122,7 +123,14 @@ export class EvaluationLogScannerSet {
122123
export async function scanLog<T extends EvaluationLogScanner>(
123124
jsonSummaryLocation: string,
124125
scanner: T,
126+
progress: ProgressCallback,
125127
): Promise<T> {
128+
progress({
129+
message: `Scanning log ${jsonSummaryLocation}`,
130+
// 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
131+
step: 1,
132+
maxStep: 2,
133+
});
126134
await readJsonlFile<SummaryEvent>(jsonSummaryLocation, async (obj) => {
127135
scanner.onEvent(obj);
128136
});

0 commit comments

Comments
 (0)