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

ci: Display performance measurement results as custom metrics #3491

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
45 changes: 21 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,25 +185,17 @@ jobs:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- uses: actions/cache/restore@v4
with:
path: perf-measures/type-check/previous-result.txt
restore-keys: |
type-check-perf-previous-result-
key: type-check-perf-previous-result-
- run: bun scripts/generate-app.ts
working-directory: perf-measures/type-check
- run: bun tsc -p tsconfig.build.json --diagnostics > result.txt
- name: Performance measurement of type check
run: |
bun scripts/generate-app.ts
bun tsc -p tsconfig.build.json --diagnostics | bun scripts/process-results.ts > diagnostics.json
working-directory: perf-measures/type-check
- run: |
{
echo 'COMPARISON<<EOF'
bun scripts/process-results.ts | column -s '|' -t
echo 'EOF'
} >> "$GITHUB_ENV"
working-directory: perf-measures/type-check
- run: echo "$COMPARISON"
name: display comparison
- name: Run octocov
uses: k1LoW/octocov-action@v1
with:
config: perf-measures/type-check/.octocov.perf-measures.yml
env:
OCTOCOV_CUSTOM_METRICS_BENCHMARK: perf-measures/type-check/diagnostics.json

perf-measures-type-check-on-main:
runs-on: ubuntu-latest
Expand All @@ -212,11 +204,16 @@ jobs:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun scripts/generate-app.ts
working-directory: perf-measures/type-check
- run: bun tsc -p tsconfig.build.json --diagnostics > previous-result.txt
- name: Performance measurement of type check
run: |
bun scripts/generate-app.ts
bun tsc -p tsconfig.build.json --diagnostics | bun scripts/process-results.ts > diagnostics.json
working-directory: perf-measures/type-check
- uses: actions/cache/save@v4
- name: Run octocov (main)
uses: k1LoW/octocov-action@v1
with:
path: perf-measures/type-check/previous-result.txt
key: type-check-perf-previous-result-${{ github.sha }}
config: perf-measures/type-check/.octocov.perf-measures.main.yml
env:
OCTOCOV_GITHUB_REF: refs/heads/main
OCTOCOV_GITHUB_SHA: none
OCTOCOV_CUSTOM_METRICS_BENCHMARK: perf-measures/type-check/diagnostics.json
13 changes: 13 additions & 0 deletions perf-measures/type-check/.octocov.perf-measures.main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
locale: "en"
repository: ${GITHUB_REPOSITORY}/perf-measures
coverage:
if: false
codeToTestRatio:
if: false
testExecutionTime:
if: false
report:
datastores:
- artifact://${GITHUB_REPOSITORY}
summary:
if: true
15 changes: 15 additions & 0 deletions perf-measures/type-check/.octocov.perf-measures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
locale: "en"
repository: ${GITHUB_REPOSITORY}/perf-measures
coverage:
if: false
codeToTestRatio:
if: false
testExecutionTime:
if: false
diff:
datastores:
- artifact://${GITHUB_REPOSITORY}
comment:
if: is_pull_request
Comment on lines +12 to +13
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete this line if you do not need it to appear as a comment in every Pull Request.
You can also check the summary only.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you think we should enable or disable it? It's cool that the performance measuring result is posted to PR as a comment, but currently, it is only a TypeScript type performance. Many PRs are not related to the type definition, so it may not be important for them.

CC: @m-shaka

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

People often ignore such an automated comment, so it may not be a problem

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We believe that the comment display itself should always be displayed when measuring performance. Displaying comments makes people aware of performance.

Many PRs are not related to the type definition, so it may not be important for them.

I thought that the essential answer to this question is that we should consider not nudging the perf-measures-type-check-on-pr Job for PRs that do not affect TypeScript type performance.

It is possible to specify a path base for the execution condition of a GHA job, but is the following the only files that affect TypeScript type performance?

  • src/client/*.ts
  • perf-measures/**/*
    If the source itself that measures performance is changed, it is also necessary to run the job

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@m-shaka @k2tzumi Thank you for the comment!

We believe that the comment display itself should always be displayed when measuring performance. Displaying comments makes people aware of performance.

I see!

It is possible to specify a path base for the execution condition of a GHA job, but is the following the only files that affect TypeScript type performance?

We have to add the following files that affect application type definitions:

  • src/types.ts
  • src/hono-base.ts
  • src/request.ts
  • src/context.ts
  • src/validator/validator.ts - it can be used in the RPC-mode.

@m-shaka

What do you think of this?

summary:
if: true
48 changes: 37 additions & 11 deletions perf-measures/type-check/scripts/process-results.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,44 @@
import * as fs from 'node:fs/promises'
import * as readline from 'node:readline';

async function main() {
const currentResult = (await fs.readFile('./result.txt')).toString().split('\n')
const previousResult = await fs.readFile('./previous-result.txt')
.then((data) => data.toString().split('\n'))
.catch(() => null)
const table = ['| | Current | Previous |', '| --- | --- | --- |']
for (const [i, line] of currentResult.entries()) {
if (line === '') {continue}
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
})
const toKebabCase = (str: string): string => {
return str
.replace(/([a-z])([A-Z])/g, '$1-$2')
.replace(/[\s_\/]+/g, '-')
.toLowerCase()
}
const metrics = []
for await (const line of rl) {
if (!line || line.trim() === '') continue
const [name, value] = line.split(':')
const mainValue = previousResult?.[i]?.split(':')?.[1]
table.push(`| ${name?.trim()} | ${value?.trim()} | ${mainValue ? mainValue.trim() : 'N/A'} |`)
const unitMatch = value?.trim().match(/^(\d+(\.\d+)?)([a-zA-Z]*)$/)
if (unitMatch) {
const [, number, , unit] = unitMatch;
metrics.push({
key: toKebabCase(name?.trim()),
name: name?.trim(),
value: parseFloat(number),
unit: unit || undefined
})
} else {
metrics.push({
key: toKebabCase(name?.trim()),
name: name?.trim(),
value: parseFloat(value?.trim()),
})
}
}
const diagnostics = {
key: "diagnostics",
name: "Compiler Diagnostics",
metrics
}
console.log(table.join('\n'))
console.log(JSON.stringify(diagnostics, null, 2))
}

main()