Skip to content

Commit

Permalink
Switch to using expId for profile and warmup data (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
smarr authored Jul 16, 2023
2 parents 479d4a3 + 9d9a9c9 commit 953224b
Show file tree
Hide file tree
Showing 16 changed files with 142 additions and 136 deletions.
23 changes: 11 additions & 12 deletions src/backend/compare/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function getProfileAsJson(

ctx.body = await getProfile(
Number(ctx.params.runId),
Number(ctx.params.trialId),
Number(ctx.params.expId),
db
);
if (ctx.body === undefined) {
Expand All @@ -36,26 +36,25 @@ export async function getProfileAsJson(

async function getProfile(
runId: number,
trialId: number,
expId: number,
db: Database
): Promise<any> {
const result = await db.query({
name: 'fetchProfileDataByRunIdTrialId',
name: 'fetchProfileDataByRunIdExpId',
text: `
SELECT substring(commitId, 1, 6) as commitid,
benchmark.name as bench, executor.name as exe, suite.name as suite,
cmdline, varValue, cores, inputSize, extraArgs,
invocation, numIterations, warmup, value as profile
FROM ProfileData
JOIN Trial ON trialId = Trial.id
JOIN Experiment ON expId = Experiment.id
JOIN Source ON source.id = sourceId
JOIN Run ON runId = run.id
JOIN Suite ON suiteId = suite.id
JOIN Benchmark ON benchmarkId = benchmark.id
JOIN Executor ON execId = executor.id
WHERE runId = $1 AND trialId = $2`,
values: [runId, trialId]
WHERE runId = $1 AND trial.expId = $2`,
values: [runId, expId]
});

const data = result.rows[0];
Expand All @@ -76,8 +75,8 @@ export async function getMeasurementsAsJson(
ctx.body = await getMeasurements(
ctx.params.projectSlug,
Number(ctx.params.runId),
Number(ctx.params.trialId1),
Number(ctx.params.trialId2),
Number(ctx.params.expId1),
Number(ctx.params.expId2),
db
);

Expand All @@ -88,8 +87,8 @@ export async function getMeasurementsAsJson(
async function getMeasurements(
projectSlug: string,
runId: number,
trialId1: number,
trialId2: number,
expId1: number,
expId2: number,
db: Database
): Promise<WarmupData | null> {
const q = {
Expand All @@ -109,9 +108,9 @@ async function getMeasurements(
JOIN Project ON Project.id = Experiment.projectId
WHERE Project.slug = $1
AND runId = $2
AND (trialId = $3 OR trialId = $4)
AND (Trial.expId = $3 OR Trial.expId = $4)
ORDER BY trialId, criterion, invocation, iteration;`,
values: [projectSlug, runId, trialId1, trialId2]
values: [projectSlug, runId, expId1, expId2]
};
const result = await db.query(q);
if (result.rows.length === 0) {
Expand Down
3 changes: 2 additions & 1 deletion src/backend/compare/db-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ function findOrConstructMeasurements(
commitId: row.commitid,
runSettings: runSetting,
runId: row.runid,
trialId: row.trialid
trialId: row.trialid,
expId: row.expid
};
benchResult.measurements.push(m);
forSuiteByBench.criteria[criterion.name] = criterion;
Expand Down
10 changes: 5 additions & 5 deletions src/backend/compare/html/stats-row-buttons-info.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
{% }

if (d.hasWarmup) {
%}<button type="button" class="btn btn-sm btn-light btn-warmup" data-content="{%= f.dataSeriesIds(d.dataSeries, d.dataSeries.runId, d.dataSeries.base.trialId, d.dataSeries.change.trialId) %}"></button>
%}<button type="button" class="btn btn-sm btn-light btn-warmup" data-content="{%= f.dataSeriesIds(d.dataSeries, d.dataSeries.runId, d.dataSeries.base.expId, d.dataSeries.change.expId) %}"></button>
{%
}

if (d.profileTrialIdBase) {
const baseTrial = d.profileTrialIdBase.trialid;
const changeTrial = d.profileTrialIdChange.trialid;
%}<button type="button" class="btn btn-sm btn-profile" data-content="{%= f.dataSeriesIds(d.dataSeries, d.profileTrialIdBase.runid, baseTrial, changeTrial) %}"></button>
if (d.profileBase) {
const baseExpId = d.profileBase.expid;
const changeExpId = d.profileChange.expid;
%}<button type="button" class="btn btn-sm btn-profile" data-content="{%= f.dataSeriesIds(d.dataSeries, d.profileBase.runid, baseExpId, changeExpId) %}"></button>
{%
}
%}<button type="button" class="btn btn-sm btn-timeline" data-content='{%- JSON.stringify(
Expand Down
11 changes: 5 additions & 6 deletions src/backend/compare/prep-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,8 @@ function addOrGetCompareStatsRow(
details: {
cmdline: measurements.runSettings.simplifiedCmdline,
envId,
profileTrialIdBase: profileIds ? profileIds[0] : false,
profileTrialIdChange:
profileIds && profileIds[1] ? profileIds[1] : false,
profileBase: profileIds ? profileIds[0] : false,
profileChange: profileIds && profileIds[1] ? profileIds[1] : false,
hasWarmup: false,
numV: countsAndMissing === null ? 0 : countsAndMissing.numV,
numC: countsAndMissing === null ? 0 : countsAndMissing.numC,
Expand Down Expand Up @@ -469,11 +468,11 @@ function getDataSeriesIds(
runId: base.runId,
base: {
commitId: base.commitId,
trialId: base.trialId
expId: base.expId
},
change: {
commitId: change.commitId,
trialId: change.trialId
expId: change.expId
}
};
}
Expand Down Expand Up @@ -527,7 +526,7 @@ async function computeStatisticsAndInlinePlot(
row.details.hasWarmup = siteConfig.canShowWarmup(change.values);

if (
(row.details.hasWarmup || row.details.profileTrialIdBase) &&
(row.details.hasWarmup || row.details.profileBase) &&
!row.details.dataSeries
) {
row.details.dataSeries = getDataSeriesIds(base, change);
Expand Down
4 changes: 2 additions & 2 deletions src/backend/db/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,7 @@ export abstract class Database {
cores as c,
inputSize as i,
extraArgs as ea,
trialId, runId
expId, runId
FROM ProfileData pd
JOIN Trial ON pd.trialId = Trial.id
JOIN Experiment e ON trial.expId = e.id
Expand All @@ -1365,7 +1365,7 @@ export abstract class Database {
(commitId = $1 OR commitId = $2)
AND e.projectId = $3
ORDER BY
b, e, s, v, c, i, ea, trialId, runId`,
b, e, s, v, c, i, ea, expId, runId, trialId`,
values: [commitId1, commitId2, projectId]
};

Expand Down
3 changes: 2 additions & 1 deletion src/backend/db/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export interface MeasurementData {
}

export interface AvailableProfile extends BenchmarkId {
trialid: number;
expid: number;
runid: number;
}

Expand Down Expand Up @@ -198,6 +198,7 @@ export interface Measurements {
envId: number;
runId: number;
trialId: number;
expId: number;
runSettings: RunSettings;
commitId: string;
stats?: SummaryStatistics;
Expand Down
3 changes: 3 additions & 0 deletions src/backend/perf-tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ const descriptions = {
'get-exp-data': 'Starting to prepare experiment data',
'project-benchmarks': 'Time of GET /rebenchdb/dash/:projectId/benchmarks',
'get-profiles':
// this url was changed to use the expId instead of the trialId
// I'll leave this unchanged here to avoid issues
// with the performance tracking
'Time of GET /rebenchdb/dash/:projectId/profiles/:runId/:trialId',
'get-measurements': 'Time of GET /rebenchdb/dash/:projectId/measurements/...'
};
Expand Down
22 changes: 11 additions & 11 deletions src/frontend/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function fetchWarmupData(
) {
const warmupR = await fetch(
`/rebenchdb/dash/${projectSlug}/measurements/` +
`${dataIds.runId}/${dataIds.ids[0].trialId}/${dataIds.ids[1].trialId}`
`${dataIds.runId}/${dataIds.ids[0].expId}/${dataIds.ids[1].expId}`
);

const warmupData: WarmupData = await warmupR.json();
Expand Down Expand Up @@ -108,15 +108,15 @@ function fetchProfile(
commitId: string,
isBase: boolean,
runId: number,
trialId: number,
expId: number,
jqInsert: JQuery<HTMLElement>
) {
const profileP = fetch(
`/rebenchdb/dash/${projectSlug}/profiles/${runId}/${trialId}`
`/rebenchdb/dash/${projectSlug}/profiles/${runId}/${expId}`
);
profileP.then(async (profileResponse) => {
const profileData = await profileResponse.json();
const profId = `prof-${commitId}-${runId}-${trialId}`;
const profId = `prof-${commitId}-${runId}-${expId}`;

const container = jqInsert.children();
const labelClass = isBase ? 'baseline' : 'change';
Expand Down Expand Up @@ -145,7 +145,7 @@ function fetchProfile(

interface DataSeriesIds {
runId: number;
ids: { commitId: string; trialId: number }[];
ids: { commitId: string; expId: number }[];
}

/**
Expand All @@ -155,10 +155,10 @@ function parseDataSeriesIds(serialized: string): DataSeriesIds {
const idPairs = serialized.split(',');
const runId = <string>idPairs.shift();

const data: { commitId: string; trialId: number }[] = [];
const data: { commitId: string; expId: number }[] = [];
for (const id of idPairs) {
const [commitId, trialId] = id.split('/');
data.push({ commitId, trialId: parseInt(trialId) });
const [commitId, expId] = id.split('/');
data.push({ commitId, expId: parseInt(expId) });
}

return { runId: parseInt(runId), ids: data };
Expand All @@ -174,8 +174,8 @@ function insertProfiles(e): void {

const { runId, ids } = parseDataSeriesIds(jqButton.data('content'));

for (const { commitId, trialId } of ids) {
if (isNaN(trialId)) {
for (const { commitId, expId } of ids) {
if (isNaN(expId)) {
continue;
}

Expand All @@ -185,7 +185,7 @@ function insertProfiles(e): void {
profileInsertTarget.after(jqInsert);
profileInsertTarget = jqInsert;
const isBase = baseHash?.startsWith(commitId) ?? false;
fetchProfile(projectSlug, commitId, isBase, runId, trialId, jqInsert);
fetchProfile(projectSlug, commitId, isBase, runId, expId, jqInsert);
}
}

Expand Down
7 changes: 3 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,11 @@ router.get('/rebenchdb/dash/:projectId/results', async (ctx) =>
router.get('/rebenchdb/dash/:projectId/timeline/:runId', async (ctx) =>
getTimelineAsJson(ctx, db)
);
router.get(
'/rebenchdb/dash/:projectSlug/profiles/:runId/:trialId',
async (ctx) => getProfileAsJson(ctx, db)
router.get('/rebenchdb/dash/:projectSlug/profiles/:runId/:expId', async (ctx) =>
getProfileAsJson(ctx, db)
);
router.get(
'/rebenchdb/dash/:projectSlug/measurements/:runId/:trialId1/:trialId2',
'/rebenchdb/dash/:projectSlug/measurements/:runId/:expId1/:expId2',
async (ctx) => getMeasurementsAsJson(ctx, db)
);
router.get('/rebenchdb/stats', async (ctx) => getSiteStatsAsJson(ctx, db));
Expand Down
8 changes: 4 additions & 4 deletions src/shared/data-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ export function benchmarkId(
export function dataSeriesIds(
ids: DataSeriesVersionComparison,
runId: number,
baseTrialId: number,
changeTrialId: number
baseExpId: number,
changeExpId: number
): string {
// format is parsed in compare.ts:insertProfiles()
return (
`${runId},${ids.base.commitId}/${baseTrialId},` +
`${ids.change.commitId}/${changeTrialId}`
`${runId},${ids.base.commitId}/${baseExpId},` +
`${ids.change.commitId}/${changeExpId}`
);
}

Expand Down
8 changes: 4 additions & 4 deletions src/shared/view-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ export interface CompareStatsRowAcrossVersionsPartial {

/**
* Identifies the set of measurements of a specific run, i.e., a concrete
* benchmark execution, and a specific trial, i.e., in a specific environment.
* benchmark execution, and a experiment.
*/
export interface DataSeriesId {
commitId: string; // this one is a bit redundant, it's implied by the trialId
trialId: number;
expId: number;
}

export interface DataSeriesVersionComparison {
Expand All @@ -86,8 +86,8 @@ export interface RunDetails {

hasWarmup: boolean;

profileTrialIdBase: AvailableProfile | false;
profileTrialIdChange: AvailableProfile | false;
profileBase: AvailableProfile | false;
profileChange: AvailableProfile | false;

dataSeries?: DataSeriesVersionComparison;

Expand Down
13 changes: 8 additions & 5 deletions tests/backend/compare/compare-view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ import {
calculateAllStatisticsAndRenderPlots,
getNavigation
} from '../../../src/backend/compare/prep-data.js';
import type { Environment } from '../../../src/backend/db/types.js';
import type {
AvailableProfile,
Environment
} from '../../../src/backend/db/types.js';
import { collateMeasurements } from '../../../src/backend/compare/db-data.js';
import { initJestMatchers } from '../../helpers.js';

Expand Down Expand Up @@ -77,18 +80,18 @@ const environments: Environment[] = [
const details: RunDetails = {
cmdline: 'som/some-command with args',
envId: 1,
profileTrialIdBase: <any>{ trialid: 11, runid: 1 },
profileTrialIdChange: <any>{ trialid: 12, runid: 1 },
profileBase: <AvailableProfile>{ expid: 11, runid: 1 },
profileChange: <AvailableProfile>{ expid: 12, runid: 1 },
hasWarmup: true,
dataSeries: {
runId: 1,
base: {
commitId: '123456',
trialId: 2
expId: 2
},
change: {
commitId: '123457',
trialId: 4
expId: 4
}
},
numV: 0,
Expand Down
3 changes: 2 additions & 1 deletion tests/backend/compare/prep-data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ function makeM(criterion, unit, envId, commitId) {
commitId,
runSettings,
runId: 1,
trialId: 1
trialId: 1,
expId: 1
};
}

Expand Down
Loading

0 comments on commit 953224b

Please sign in to comment.