-
Notifications
You must be signed in to change notification settings - Fork 22
Feat/ci benchmark #669
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
Open
simplyme0823
wants to merge
42
commits into
main
Choose a base branch
from
feat/ci-benchmark
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat/ci benchmark #669
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
6dac56a
Add CodSpeed performance benchmarks for linter
codspeed-hq[bot] 6c1acee
Remove -timeout flag from CodSpeed benchmark command
codspeed-hq[bot] 5a2aa8d
chore: save
d57ace8
chore: save
c67f6fc
chore: save
399e4ec
chore: lint
afc05b7
chore: save
2a7cf75
chore: lint
0185062
chore: js benchmark
8d1f900
chore: lint
07bdebd
chore: update pnpm lock
ced8094
chore: update yml
36a1762
chore: fix codspeed version
3452dad
chore: update yml
simplyme0823 0ca6314
chore: save
simplyme0823 4255736
chore: save
simplyme0823 bae50fa
chore: save
simplyme0823 a2700b8
chore: use tinybench
simplyme0823 a441cdb
chore: use tsc
simplyme0823 9bc7656
chore: save
simplyme0823 68e03b5
chore: save
simplyme0823 119ca06
chore: save
simplyme0823 cbabb9f
chore: save
simplyme0823 910847a
chore: save
simplyme0823 eec4134
chore: save
simplyme0823 2ebe675
chore: save
simplyme0823 5736e0c
chore: fix ci
simplyme0823 b7f9f94
chore: save
simplyme0823 a09f5bb
chore: save
simplyme0823 6e25ba8
chore: update runners
4e3b823
chore: update runners
99f22a2
chore: update runners
a8576c2
chore: update runners
9fe2419
chore: update runners
c29271d
chore: update runners
bf3357b
fix: tinybench
bcab02f
fix: tinybench
959c5fb
chore: runner
65133d9
feat: add js time
3b95f97
feat: upload js time
abdc37a
feat: mode
113090b
chore: merge ci
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| name: Setup CodSpeed | ||
| description: Install the pinned CodSpeed runner with retry and hash verification | ||
|
|
||
| inputs: | ||
| runner-version: | ||
| description: CodSpeed runner version to install. | ||
| default: '4.13.0' | ||
| installer-sha256: | ||
| description: Expected SHA-256 for the installer script. | ||
| default: '55d150594275efb4a983b2f5626e84646269f42678f72554a26d6ce25b64e2d4' | ||
| download-retries: | ||
| description: Number of download attempts before failing. | ||
| default: '5' | ||
| retry-delay-seconds: | ||
| description: Delay between download attempts. | ||
| default: '3' | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Install CodSpeed runner | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| RUNNER_VERSION="${{ inputs.runner-version }}" | ||
| EXPECTED_HASH="${{ inputs.installer-sha256 }}" | ||
| DOWNLOAD_RETRIES="${{ inputs.download-retries }}" | ||
| RETRY_DELAY_SECONDS="${{ inputs.retry-delay-seconds }}" | ||
| INSTALLER_URL="https://codspeed.io/v${RUNNER_VERSION}/install.sh" | ||
| INSTALLER_TMP="$(mktemp)" | ||
| CURL_ERR="$(mktemp)" | ||
| trap 'rm -f "$INSTALLER_TMP" "$CURL_ERR"' EXIT | ||
|
|
||
| checksum() { | ||
| if command -v sha256sum >/dev/null 2>&1; then | ||
| sha256sum "$1" | awk '{print $1}' | ||
| else | ||
| shasum -a 256 "$1" | awk '{print $1}' | ||
| fi | ||
| } | ||
|
|
||
| attempt=1 | ||
| while true; do | ||
| : >"$INSTALLER_TMP" | ||
| : >"$CURL_ERR" | ||
| CURL_EXIT=0 | ||
| HTTP_CODE="" | ||
|
|
||
| if HTTP_CODE="$(curl -sSL -o "$INSTALLER_TMP" -w "%{http_code}" "$INSTALLER_URL" 2>"$CURL_ERR")"; then | ||
| CURL_EXIT=0 | ||
| else | ||
| CURL_EXIT=$? | ||
| fi | ||
|
|
||
| if [ "$CURL_EXIT" -eq 0 ] && [ "$HTTP_CODE" -lt 400 ]; then | ||
| break | ||
| fi | ||
|
|
||
| if [ "$CURL_EXIT" -eq 0 ] && [ -n "$HTTP_CODE" ] && [ "$HTTP_CODE" -ge 400 ]; then | ||
| FAILURE_REASON="HTTP ${HTTP_CODE} - $(cat "$INSTALLER_TMP")" | ||
| else | ||
| FAILURE_REASON="$(cat "$CURL_ERR")" | ||
| fi | ||
|
|
||
| RETRYABLE_FAILURE=1 | ||
| if [ "$CURL_EXIT" -eq 0 ]; then | ||
| case "$HTTP_CODE" in | ||
| 408|429|500|502|503|504) | ||
| RETRYABLE_FAILURE=1 | ||
| ;; | ||
| *) | ||
| RETRYABLE_FAILURE=0 | ||
| ;; | ||
| esac | ||
| fi | ||
|
|
||
| if [ "$RETRYABLE_FAILURE" -eq 0 ] || [ "$attempt" -ge "$DOWNLOAD_RETRIES" ]; then | ||
| echo "::error title=Failed to install CodSpeed CLI::Installation of CodSpeed CLI with version ${RUNNER_VERSION} failed after ${DOWNLOAD_RETRIES} attempts.%0AReason: ${FAILURE_REASON}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "CodSpeed installer download failed on attempt ${attempt}/${DOWNLOAD_RETRIES}: ${FAILURE_REASON}" | ||
| attempt=$((attempt + 1)) | ||
| sleep "$RETRY_DELAY_SECONDS" | ||
| done | ||
|
|
||
| ACTUAL_HASH="$(checksum "$INSTALLER_TMP")" | ||
| if [ "$ACTUAL_HASH" != "$EXPECTED_HASH" ]; then | ||
| echo "::error::Installer hash mismatch for version ${RUNNER_VERSION}. Expected: ${EXPECTED_HASH}, Got: ${ACTUAL_HASH}" | ||
| exit 1 | ||
| fi | ||
| echo "Installer hash verified for version ${RUNNER_VERSION}" | ||
|
|
||
| bash "$INSTALLER_TMP" --quiet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "strconv" | ||
| "testing" | ||
|
|
||
| "github.com/microsoft/typescript-go/shim/bundled" | ||
| "github.com/microsoft/typescript-go/shim/compiler" | ||
| "github.com/microsoft/typescript-go/shim/tspath" | ||
| "github.com/microsoft/typescript-go/shim/vfs/cachedvfs" | ||
| "github.com/microsoft/typescript-go/shim/vfs/osvfs" | ||
| rslintconfig "github.com/web-infra-dev/rslint/internal/config" | ||
| "github.com/web-infra-dev/rslint/internal/utils" | ||
| ) | ||
|
|
||
| var benchmarkWorkspaceOwnershipSink int | ||
|
|
||
| func BenchmarkWorkspaceOwnership(b *testing.B) { | ||
| rootDir := b.TempDir() | ||
| packageNames := []string{"pkg-a", "pkg-b", "pkg-c"} | ||
|
|
||
| programs := make([]*compiler.Program, 0, len(packageNames)) | ||
| configMap := map[string]rslintconfig.RslintConfig{ | ||
| tspath.NormalizePath(rootDir): nil, | ||
| } | ||
|
|
||
| for _, packageName := range packageNames { | ||
| configDir := filepath.Join(rootDir, "packages", packageName) | ||
| programs = append(programs, createWorkspaceBenchmarkProgram(b, configDir, 20)) | ||
| normalizedDir := tspath.NormalizePath(configDir) | ||
| configMap[normalizedDir] = nil | ||
| } | ||
|
|
||
| b.ReportAllocs() | ||
| b.ResetTimer() | ||
|
|
||
| for b.Loop() { | ||
| fileOwner := buildFileOwnerMap(programs, configMap) | ||
| benchmarkWorkspaceOwnershipSink = len(fileOwner) | ||
| } | ||
| } | ||
|
|
||
| func createWorkspaceBenchmarkProgram(b *testing.B, configDir string, fileCount int) *compiler.Program { | ||
| b.Helper() | ||
|
|
||
| srcDir := filepath.Join(configDir, "src") | ||
| if err := os.MkdirAll(srcDir, 0o755); err != nil { | ||
| b.Fatalf("failed to create workspace benchmark dir %s: %v", srcDir, err) | ||
| } | ||
|
|
||
| for i := range fileCount { | ||
| filePath := filepath.Join(srcDir, "file"+strconv.Itoa(i)+".ts") | ||
| content := "export const value" + strconv.Itoa(i) + " = " + strconv.Itoa(i) + ";\n" | ||
| if err := os.WriteFile(filePath, []byte(content), 0o644); err != nil { | ||
| b.Fatalf("failed to write %s: %v", filePath, err) | ||
| } | ||
| } | ||
|
|
||
| tsconfig := `{"compilerOptions":{"target":"esnext","module":"esnext"},"include":["src/**/*.ts"]}` | ||
| if err := os.WriteFile(filepath.Join(configDir, "tsconfig.json"), []byte(tsconfig), 0o644); err != nil { | ||
| b.Fatalf("failed to write tsconfig.json: %v", err) | ||
| } | ||
|
|
||
| fs := bundled.WrapFS(cachedvfs.From(osvfs.FS())) | ||
| host := utils.CreateCompilerHost(configDir, fs) | ||
| program, err := utils.CreateProgram(true, fs, configDir, "tsconfig.json", host) | ||
| if err != nil { | ||
| b.Fatalf("failed to create program: %v", err) | ||
| } | ||
|
|
||
| return program | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.