Skip to content

Commit 341ec65

Browse files
authored
Merge pull request #3819 from github/esbena/annotated-performance-view
Hackathon: description on top of performance table
2 parents 5464a46 + 82a00b6 commit 341ec65

File tree

12 files changed

+410
-157
lines changed

12 files changed

+410
-157
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
type VariantId = string;
2+
type SourceId = string;
3+
type TargetId = string;
4+
5+
type TargetInfo = {
6+
target_id: TargetId;
7+
variant_id: VariantId;
8+
source_id: SourceId;
9+
};
10+
11+
type SourceInfo = {
12+
source_id: SourceId;
13+
repository: string;
14+
sha: string;
15+
};
16+
17+
export type ArtifactDownload = {
18+
repository: string;
19+
run_id: number;
20+
artifact_name: string;
21+
};
22+
23+
type TargetDownloads = {
24+
"evaluator-logs": ArtifactDownload;
25+
};
26+
27+
export type MinimalDownloadsType = {
28+
sources: {
29+
[source: SourceId]: { info: SourceInfo };
30+
};
31+
targets: {
32+
[target: string]: {
33+
info: TargetInfo;
34+
downloads: TargetDownloads;
35+
};
36+
};
37+
};
38+
39+
export const dcaControllerRepository = {
40+
owner: "github",
41+
repo: "codeql-dca-main",
42+
};

extensions/ql-vscode/src/common/interface-types.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ import type {
2727
} from "./raw-result-types";
2828
import type { AccessPathSuggestionOptions } from "../model-editor/suggestions";
2929
import type { ModelEvaluationRunState } from "../model-editor/shared/model-evaluation-run-state";
30-
import type { PerformanceComparisonDataFromLog } from "../log-insights/performance-comparison";
30+
import type {
31+
ComparePerformanceDescriptionData,
32+
PerformanceComparisonDataFromLog,
33+
} from "../log-insights/performance-comparison";
3134

3235
/**
3336
* This module contains types and code that are shared between
@@ -398,9 +401,9 @@ export interface SetComparisonsMessage {
398401
}
399402

400403
export type ToComparePerformanceViewMessage = SetPerformanceComparisonQueries;
401-
402404
export interface SetPerformanceComparisonQueries {
403405
readonly t: "setPerformanceComparison";
406+
readonly description: ComparePerformanceDescriptionData;
404407
readonly from: PerformanceComparisonDataFromLog;
405408
readonly to: PerformanceComparisonDataFromLog;
406409
readonly comparison: boolean;

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { withProgress } from "../common/vscode/progress";
1717
import { telemetryListener } from "../common/vscode/telemetry";
1818
import type { ResultsView } from "../local-queries";
1919
import { scanLog } from "../log-insights/log-scanner";
20+
import type { ComparePerformanceDescriptionData } from "../log-insights/performance-comparison";
2021
import { PerformanceOverviewScanner } from "../log-insights/performance-comparison";
2122
import type { HistoryItemLabelProvider } from "../query-history/history-item-label-provider";
2223
import { RemoteLogs } from "./remote-logs";
@@ -45,7 +46,11 @@ export class ComparePerformanceView extends AbstractWebview<
4546
);
4647
}
4748

48-
async showResults(fromJsonLog: string, toJsonLog: string) {
49+
async showResults(
50+
fromJsonLog: string | undefined,
51+
toJsonLog: string,
52+
description: ComparePerformanceDescriptionData,
53+
) {
4954
const panel = await this.getPanel();
5055
panel.reveal(undefined, false);
5156

@@ -69,19 +74,20 @@ export class ComparePerformanceView extends AbstractWebview<
6974
}
7075

7176
const [fromPerf, toPerf] = await Promise.all([
72-
fromJsonLog === ""
73-
? new PerformanceOverviewScanner()
74-
: scanLogWithProgress(fromJsonLog, "1/2"),
75-
scanLogWithProgress(toJsonLog, fromJsonLog === "" ? "1/1" : "2/2"),
77+
fromJsonLog
78+
? scanLogWithProgress(fromJsonLog, "1/2")
79+
: new PerformanceOverviewScanner(),
80+
scanLogWithProgress(toJsonLog, fromJsonLog ? "2/2" : "1/1"),
7681
]);
7782

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

8085
await this.postMessage({
8186
t: "setPerformanceComparison",
87+
description,
8288
from: fromPerf.getData(),
8389
to: toPerf.getData(),
84-
comparison: fromJsonLog !== "",
90+
comparison: !!fromJsonLog,
8591
});
8692
}
8793

@@ -140,6 +146,6 @@ export class ComparePerformanceView extends AbstractWebview<
140146
);
141147
return;
142148
}
143-
await this.showResults(result.before, result.after);
149+
await this.showResults(result.before, result.after, result.description);
144150
}
145151
}

extensions/ql-vscode/src/compare-performance/remote-logs.ts

Lines changed: 33 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,17 @@ import { basename, dirname, join, relative } from "path";
1414
import { Uri, window, workspace } from "vscode";
1515
import type { CodeQLCliServer } from "../codeql-cli/cli";
1616
import type { App } from "../common/app";
17+
import type { ArtifactDownload, MinimalDownloadsType } from "../common/dca";
18+
import { dcaControllerRepository } from "../common/dca";
1719
import { createTimeoutSignal } from "../common/fetch-stream";
1820
import { extLogger } from "../common/logging/vscode";
1921
import type { ProgressCallback } from "../common/vscode/progress";
2022
import { reportStreamProgress, withProgress } from "../common/vscode/progress";
2123
import { downloadTimeout, GITHUB_URL } from "../config";
2224
import { QueryOutputDir } from "../local-queries/query-output-dir";
25+
import type { ComparePerformanceDescriptionData } from "../log-insights/performance-comparison";
2326
import { tmpDir } from "../tmp-dir";
2427

25-
type VariantId = string;
26-
type SourceId = string;
27-
type TargetId = string;
28-
29-
type TargetInfo = {
30-
target_id: TargetId;
31-
variant_id: VariantId;
32-
source_id: SourceId;
33-
};
34-
35-
type ArtifactDownload = {
36-
repository: string;
37-
run_id: number;
38-
artifact_name: string;
39-
};
40-
41-
type TargetDownloads = {
42-
"evaluator-logs": ArtifactDownload;
43-
};
44-
45-
type MinimalDownloadsType = {
46-
targets: {
47-
[target: string]: {
48-
info: TargetInfo;
49-
downloads: TargetDownloads;
50-
};
51-
};
52-
};
53-
54-
const dcaControllerRepository = {
55-
owner: "github",
56-
repo: "codeql-dca-main",
57-
};
5828
export class RemoteLogs {
5929
private LOG_DOWNLOAD_AND_PROCESS_PROGRESS_STEPS = 4;
6030
private PICK_TARGETS_PROGRESS_STEPS = 4;
@@ -283,6 +253,7 @@ export class RemoteLogs {
283253
| {
284254
before: string;
285255
after: string;
256+
description: ComparePerformanceDescriptionData;
286257
}
287258
| undefined
288259
> {
@@ -299,7 +270,11 @@ export class RemoteLogs {
299270
if (processed.some((d) => typeof d === "undefined")) {
300271
throw new Error("Silently failed to download or process some logs!?");
301272
}
302-
return { before: processed[0]!, after: processed[1]! };
273+
return {
274+
before: processed[0]!,
275+
after: processed[1]!,
276+
description: picked.description,
277+
};
303278
}
304279

305280
/**
@@ -489,20 +464,21 @@ export class RemoteLogs {
489464
};
490465
}
491466

492-
private async getPotentialTargetInfos(
493-
experimentName: string,
494-
): Promise<Array<MinimalDownloadsType["targets"]["string"]>> {
467+
private async getPotentialTargetInfos(experimentName: string): Promise<{
468+
targets: Array<MinimalDownloadsType["targets"]["string"]>;
469+
info: MinimalDownloadsType;
470+
}> {
495471
const tasksDir = await this.getTasksForExperiment(experimentName);
496472

497473
const downloads = await this.getDownloadsFromTasks(tasksDir);
498474
void extLogger.log(
499475
`Found ${Object.keys(downloads.targets).length} potential targets in experiment ${experimentName}`,
500476
);
501-
return Object.values(downloads.targets);
477+
return { targets: Object.values(downloads.targets), info: downloads };
502478
}
503479

504480
/**
505-
* Gets the "downloads" metadata from a taksks directory.
481+
* Gets the "downloads" metadata from a tasks directory.
506482
*/
507483
private async getDownloadsFromTasks(
508484
tasksDir: string,
@@ -669,6 +645,7 @@ export class RemoteLogs {
669645
| {
670646
before: ArtifactDownload;
671647
after: ArtifactDownload;
648+
description: ComparePerformanceDescriptionData;
672649
}
673650
| undefined
674651
> {
@@ -696,8 +673,9 @@ export class RemoteLogs {
696673
step: 2,
697674
maxStep: this.PICK_TARGETS_PROGRESS_STEPS,
698675
});
699-
const targetInfos = await this.getPotentialTargetInfos(experimentChoice);
700-
if (targetInfos.length === 0) {
676+
const { targets, info } =
677+
await this.getPotentialTargetInfos(experimentChoice);
678+
if (targets.length === 0) {
701679
throw new Error(
702680
`No targets found in experiment ${experimentChoice}. Is the experiment complete enough yet?`,
703681
);
@@ -708,7 +686,7 @@ export class RemoteLogs {
708686
maxStep: this.PICK_TARGETS_PROGRESS_STEPS,
709687
});
710688
const targetChoice1 = await window.showQuickPick(
711-
targetInfos.map((t) => t.info.target_id),
689+
targets.map((t) => t.info.target_id),
712690
{
713691
title: `Pick target 1`,
714692
ignoreFocusOut: true,
@@ -717,7 +695,7 @@ export class RemoteLogs {
717695
if (!targetChoice1) {
718696
return undefined;
719697
}
720-
const targetInfoChoice1 = targetInfos.find(
698+
const targetInfoChoice1 = targets.find(
721699
(t) => t.info.target_id === targetChoice1,
722700
)!;
723701
progress?.({
@@ -726,7 +704,7 @@ export class RemoteLogs {
726704
maxStep: this.PICK_TARGETS_PROGRESS_STEPS,
727705
});
728706
const targetChoice2 = await window.showQuickPick(
729-
targetInfos
707+
targets
730708
.filter(
731709
(t) =>
732710
t.info.target_id !== targetChoice1 &&
@@ -748,10 +726,19 @@ export class RemoteLogs {
748726
void extLogger.log(
749727
`Picked ${experimentChoice} ${targetChoice1} ${targetChoice2}`,
750728
);
729+
const targetInfoChoice2 = targets.find(
730+
(t) => t.info.target_id === targetChoice2,
731+
)!;
751732
return {
752733
before: targetInfoChoice1.downloads["evaluator-logs"],
753-
after: targetInfos.find((t) => t.info.target_id === targetChoice2)!
754-
.downloads["evaluator-logs"],
734+
after: targetInfoChoice2.downloads["evaluator-logs"],
735+
description: {
736+
kind: "remote-logs",
737+
experimentName: experimentChoice,
738+
fromTarget: targetChoice1,
739+
toTarget: targetChoice2,
740+
info,
741+
},
755742
};
756743
}
757744
}

0 commit comments

Comments
 (0)