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

Fix benchmark debug action #4187

Merged
merged 4 commits into from
Nov 1, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
description: 'Branch or tag ref to check out'
type: string
required: false
default: 'main'
default: ''
artifact_name:
description: 'Name of the artifact to upload'
type: string
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/run-bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ jobs:
with:
name: results
path: benches/results/${{ inputs.benchmark }}.json
- name: Anaylze logs if present
working-directory: benches
run: '[ -d logs ] && npm run analyze ${{ inputs.benchmark }} || echo "No logs to analyze"'
- name: Tar logs if present
working-directory: benches
run: '[ -d logs ] && tar -zcvf ${{ inputs.benchmark}}_logs.tgz logs || echo "No logs found"'
Expand Down
30 changes: 17 additions & 13 deletions .github/workflows/single-bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ on:
type: boolean
default: true
required: false
timeout:
description: 'How many minutes to give the benchmark to run before timing out and failing'
type: number
default: 20
required: false
# A bug in GitHub actions prevents us from passing numbers (as either
# number or string type) to called workflows. So disabling this for now.
# See: https://github.com/orgs/community/discussions/67182
#
# timeout:
# description: 'How many minutes to give the benchmark to run before timing out and failing'
# type: number
# default: 20
# required: false

jobs:
build_local:
Expand All @@ -57,17 +61,17 @@ jobs:
with:
name: npm-package
- run: mv preact.tgz preact-local.tgz
- name: Upload locally built preact package
uses: actions/upload-artifact@v3
with:
name: bench-environment
path: preact-local.tgz
- name: Clear working directory
run: |
ls -al
rm -rf *
echo "===================="
ls -al
- name: Upload locally built preact package
uses: actions/upload-artifact@v3
with:
name: bench-environment
path: preact-local.tgz
- name: Download base package
uses: actions/download-artifact@v3
with:
Expand All @@ -80,10 +84,10 @@ jobs:
path: preact-main.tgz

benchmark:
name: Bench ${{ inputs.benchmark}}
name: Bench ${{ inputs.benchmark }}
uses: ./.github/workflows/run-bench.yml
needs: prepare
with:
benchmark: ${{ inputs.benchmark}}
timeout: ${{ inputs.timeout }}
benchmark: ${{ inputs.benchmark }}
trace: ${{ inputs.trace }}
# timeout: ${{ inputs.timeout }}
33 changes: 20 additions & 13 deletions benches/scripts/analyze.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function setInMapArray(map, key, index, value) {
function logDifferences(key, results) {
let withDifferences = computeDifferences(results);
console.log();
let { fixed, unfixed } = automaticResultTable(withDifferences);
let { unfixed } = automaticResultTable(withDifferences);
// console.log(horizontalTermResultTable(fixed));
console.log(key);
console.log(verticalTermResultTable(unfixed));
Expand All @@ -96,7 +96,7 @@ function logDifferences(key, results) {
/**
* @param {string} version
* @param {string[]} logPaths
* @param {(logs: TraceEvent[], logFilePath: string) => number} [getThreadId]
* @param {(logs: TraceEvent[], logFilePath: string) => number | null} [getThreadId]
* @param {(log: TraceEvent) => boolean} [trackEventsIn]
* @returns {Promise<Map<string, ResultStats>>}
*/
Expand All @@ -108,6 +108,10 @@ async function getStatsFromLogs(version, logPaths, getThreadId, trackEventsIn) {
const logs = JSON.parse(await readFile(logPath, 'utf8'));

let tid = getThreadId ? getThreadId(logs, logPath) : null;
if (tid == null) {
console.warn(`Could not find threadId for ${logPath}. Skipping...`);
continue;
}

/** @type {Array<{ id: string; start: number; end: number; }>} Determine what durations to track events under */
const parentLogs = [];
Expand Down Expand Up @@ -245,18 +249,10 @@ async function getStatsFromLogs(version, logPaths, getThreadId, trackEventsIn) {
/**
* @param {import('./tracing').TraceEvent[]} logs
* @param {string} logFilePath
* @returns {number}
* @returns {number | null}
*/
function getDurationThread(logs, logFilePath) {
let log = logs.find(isDurationLog);

if (log == null) {
throw new Error(
`Could not find blink.user_timing log for "run-final" or "duration" in ${logFilePath}.`
);
} else {
return log.tid;
}
return logs.find(isDurationLog)?.tid ?? null;
}

/**
Expand All @@ -273,7 +269,8 @@ function isDurationLog(log) {
);
}

export async function analyze() {
/** @param {string} requestedBench */
export async function analyze(requestedBench) {
// const frameworkNames = await readdir(p('logs'));
const frameworkNames = frameworks.map(f => f.label);
const listAtEnd = [
Expand All @@ -296,6 +293,16 @@ export async function analyze() {
if (benchmarkNames.length == 0) {
console.log(`No benchmarks or results found in "${baseTraceLogDir()}".`);
return;
} else if (requestedBench) {
if (benchmarkNames.includes(requestedBench)) {
selectedBench = requestedBench;
} else {
console.log(
`Could not find benchmark "${requestedBench}". Available benchmarks:`
);
console.log(benchmarkNames);
return;
}
} else if (benchmarkNames.length == 1) {
selectedBench = benchmarkNames[0];
} else {
Expand Down
7 changes: 6 additions & 1 deletion benches/scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,17 @@ prog
)
.action(runDeopts);

// Test
// - (no args)
// - 02_replace1k
prog
.command('analyze')
.command('analyze [benchmark]')
.describe(
'Analyze the trace logs created by running benchmarks with the --trace flag'
)
.example('analyze')
.example('analyze 02_replace1k')
.example('analyze many_updates')
.action(analyze);

prog.parse(process.argv);