Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hackathon: support mono view of remote logs #3824

Merged
merged 4 commits into from
Nov 15, 2024
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
Expand Up @@ -65,7 +65,7 @@ export class ComparePerformanceView extends AbstractWebview<
const bytes = statSync(log).size;
return withProgress(
async (progress) =>
scanLog(log, new PerformanceOverviewScanner(), progress),
await scanLog(log, new PerformanceOverviewScanner(), progress),

{
title: `Scanning evaluator log ${logDescription} (${(bytes / 1024 / 1024).toFixed(1)} MB)`,
Expand Down
43 changes: 34 additions & 9 deletions extensions/ql-vscode/src/compare-performance/remote-logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export class RemoteLogs {
*/
public async downloadAndProcess(): Promise<
| {
before: string;
before: string | undefined;
after: string;
description: ComparePerformanceDescriptionData;
}
Expand All @@ -262,17 +262,26 @@ export class RemoteLogs {
void extLogger.log("No targets picked, aborting download");
return undefined;
}
const processed = await Promise.all([
this.downloadAndProcessLogsForTarget(picked.before),
const [processedBefore, processedAfter] = await Promise.all([
...(picked.before
? [this.downloadAndProcessLogsForTarget(picked.before)]
: [undefined]),
this.downloadAndProcessLogsForTarget(picked.after),
]);

if (processed.some((d) => typeof d === "undefined")) {
throw new Error("Silently failed to download or process some logs!?");
if (picked.before && processedBefore === undefined) {
throw new Error(
"Silently failed to download or process the 'before' logs!?",
);
}
if (processedAfter === undefined) {
throw new Error(
"Silently failed to download or process the 'after' logs!?",
);
}
return {
before: processed[0]!,
after: processed[1]!,
before: processedBefore,
after: processedAfter,
description: picked.description,
};
}
Expand Down Expand Up @@ -643,7 +652,7 @@ export class RemoteLogs {

private async pickTargets(progress?: ProgressCallback): Promise<
| {
before: ArtifactDownload;
before?: ArtifactDownload;
after: ArtifactDownload;
description: ComparePerformanceDescriptionData;
}
Expand Down Expand Up @@ -703,6 +712,7 @@ export class RemoteLogs {
step: 4,
maxStep: this.PICK_TARGETS_PROGRESS_STEPS,
});
const NONE = "NONE";
const targetChoice2 = await window.showQuickPick(
targets
.filter(
Expand All @@ -714,7 +724,8 @@ export class RemoteLogs {
t.info.source_id === targetInfoChoice1.info.source_id &&
t.info.variant_id !== targetInfoChoice1.info.variant_id,
)
.map((t) => t.info.target_id),
.map((t) => t.info.target_id)
.concat(NONE),
{
title: `Pick target 2`,
ignoreFocusOut: true,
Expand All @@ -726,6 +737,20 @@ export class RemoteLogs {
void extLogger.log(
`Picked ${experimentChoice} ${targetChoice1} ${targetChoice2}`,
);
if (targetChoice2 === NONE) {
return {
// the convention downstream is that "from" can be optional, but here it is the opposite ...
before: undefined,
after: targetInfoChoice1.downloads["evaluator-logs"],
description: {
kind: "remote-logs",
experimentName: experimentChoice,
fromTarget: undefined,
toTarget: targetChoice1,
info,
},
};
}
const targetInfoChoice2 = targets.find(
(t) => t.info.target_id === targetChoice2,
)!;
Expand Down
9 changes: 7 additions & 2 deletions extensions/ql-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1225,9 +1225,14 @@ async function showPerformanceComparison(
const fromLog = from?.evalutorLogPaths?.jsonSummary;
const toLog = to.evalutorLogPaths?.jsonSummary;

if (fromLog === undefined || toLog === undefined) {
if (from && fromLog === undefined) {
return extLogger.showWarningMessage(
`Cannot compare performance as the structured logs are missing. Did they queries complete normally?`,
`Cannot compare performance as the "from" structured logs are missing. Did they queries complete normally?`,
);
}
if (toLog === undefined) {
return extLogger.showWarningMessage(
`Cannot compare performance as the "to" structured logs are missing. Did they queries complete normally?`,
);
}
if (from) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export type ComparePerformanceDescriptionData =
| {
kind: "remote-logs";
experimentName: string;
fromTarget: string;
fromTarget?: string;
toTarget: string;
info: MinimalDownloadsType;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ export const ComparePerformanceLocalRunDescription = ({
}: Props) => {
return (
<div>
(fromQuery?
<strong>
Comparison of local runs of {fromQuery} and {toQuery}
</strong>
: Local run of {toQuery})
{fromQuery ? (
<strong>
Comparison of local runs of {fromQuery} and {toQuery}
</strong>
) : (
<strong>Local run of {toQuery}</strong>
)}
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const TargetRow = ({
info,
}: {
kind: string;
target: Props["fromTarget"] | Props["toTarget"];
target: Exclude<Props["fromTarget"] | Props["toTarget"], undefined>;
info: Props["info"];
}) => {
const targetObj = info.targets[target];
Expand Down Expand Up @@ -90,7 +90,9 @@ const TargetTable = ({
</tr>
</thead>
<tbody>
<TargetRow kind="from" target={fromTarget} info={info} />
{fromTarget ? (
<TargetRow kind="from" target={fromTarget} info={info} />
) : null}
<TargetRow kind="to" target={toTarget} info={info} />
</tbody>
</table>
Expand Down
Loading