Skip to content

Commit 8fd7673

Browse files
committed
feat: parallel log scanning
1 parent d78338e commit 8fd7673

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";
@@ -58,12 +59,24 @@ export class ComparePerformanceView extends AbstractWebview<
5859

5960
await this.waitForPanelLoaded();
6061

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

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

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)