-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor logic to remove old data strucuture and compare performance #2
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
Changes from all commits
26634bf
a91051d
feff7dd
ede272a
c30021c
8c7f380
70f273b
0231bda
6755ef7
7631a0d
84ec227
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/usr/bin/env bash | ||
| # Fetch danh sách repo (pinned) trong .github/benches/repos/sources.txt về | ||
| # .github/benches/repos/checkout/<name>, rồi ghi đường dẫn TUYỆT ĐỐI vào | ||
| # .github/benches/repos/list.txt để codegraph-bench (CodSpeed) đọc qua env | ||
| # CODEGRAPH_BENCH_REPOS_LIST (${{ github.workspace }}/.github/benches/repos/list.txt). | ||
| # | ||
| # Chạy local: bash .github/benches/fetch_repos.sh | ||
| # Chạy trong CI (codspeed.yml) trước `cargo codspeed build`. | ||
| set -euo pipefail | ||
|
|
||
| DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| OUT="$DIR/repos/checkout" | ||
| LIST="$DIR/repos/list.txt" | ||
| SRC="$DIR/repos/sources.txt" | ||
|
|
||
| mkdir -p "$OUT" | ||
| : > "$LIST" | ||
|
|
||
| # Mỗi dòng: <name>|<url>|<commit> | ||
| # `|| [ -n "$name" ]` xử lý dòng cuối không có trailing `\n`. | ||
| while IFS='|' read -r name url commit || [ -n "$name" ]; do | ||
| name="$(printf '%s' "$name" | xargs)" # trim | ||
| [ -z "$name" ] && continue | ||
| [[ "$name" == \#* ]] && continue | ||
| dest="$OUT/$name" | ||
| if [ ! -d "$dest/.git" ]; then | ||
| echo ">> clone $name ..." | ||
| git clone --quiet --filter=blob:none --no-checkout "$url" "$dest" | ||
| fi | ||
| echo ">> checkout $name @ ${commit:0:12}" | ||
| git -C "$dest" fetch --quiet --depth 1 origin "$commit" | ||
| git -C "$dest" checkout --quiet "$commit" | ||
| echo "$dest" >> "$LIST" | ||
|
Comment on lines
+23
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Reconcile reused checkouts before fetching. When 🤖 Prompt for AI Agents |
||
| done < "$SRC" | ||
|
|
||
| echo "=== repos ready (${LIST}) ===" | ||
| cat "$LIST" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Danh sách repo codspeed để benchmark — mỗi dòng: <name>|<git-url>|<commit-sha> | ||
| # | ||
| # Sửa/thêm dòng để thay đổi tập repo (được fetch về theo `benches/fetch_repos.sh`). | ||
| # Commit SHA cố định (pinned) để dữ liệu đầu vào giữ nguyên giữa các lần chạy, | ||
| # giúp CodSpeed so sánh performance ổn định. Muốn cập nhật thì đổi SHA rồi re-run. | ||
| # | ||
| # Các repo nhỏ, đa ngôn ngữ để phủ parser của codegraph-extract: | ||
| hello|https://github.com/golang/example|7f05d217867b2af52b0a28c6d1c91df97e1b5b39 | ||
| serde-json|https://github.com/serde-rs/json|a3e9758ffc88247ab82182cb2505867768a702e3 | ||
| flask|https://github.com/pallets/flask|6a2f545bfd8ed31e19066a299296917e034aca58 | ||
| express|https://github.com/expressjs/express|a3714473feb3d2908add734d340e7755fd85e0a3 |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,52 @@ | ||||||||||||||||||||||||||||||
| name: CodSpeed | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||
| push: | ||||||||||||||||||||||||||||||
| branches: | ||||||||||||||||||||||||||||||
| - "main" | ||||||||||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||||||||||
| # `workflow_dispatch` cho phép CodSpeed trigger backtest performance | ||||||||||||||||||||||||||||||
| # để sinh dữ liệu ban đầu. | ||||||||||||||||||||||||||||||
| workflow_dispatch: | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||||||
| id-token: write # OpenID Connect auth với CodSpeed | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||
| # Danh sách repo (1 path/dòng) sẽ được bench — do .github/benches/fetch_repos.sh | ||||||||||||||||||||||||||||||
| # ghi ra từ .github/benches/repos/sources.txt. codegraph-bench đọc env này khi chạy. | ||||||||||||||||||||||||||||||
| # Dùng path TUYỆT ĐỐI để không phụ thuộc CWD của `cargo codspeed run`. | ||||||||||||||||||||||||||||||
| CODEGRAPH_BENCH_REPOS_LIST: ${{ github.workspace }}/.github/benches/repos/list.txt | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||
| # Performance benchmarks: extract → index → query trên danh sách repo thật | ||||||||||||||||||||||||||||||
| # (xem crates/codegraph-bench, bench target `codspeed`). | ||||||||||||||||||||||||||||||
| codspeed: | ||||||||||||||||||||||||||||||
| name: Bench | ||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== workflow file =="
if [ -f .github/workflows/codspeed.yml ]; then
cat -n .github/workflows/codspeed.yml
else
echo "missing .github/workflows/codspeed.yml"
fi
echo
echo "== workflow references to checkout/persist/npm install/code execution =="
rg -n "actions/checkout|git (clone|commit|push|push-default|config|submodule|fetch|pull|push)\s|--depth|persist-credentials|npm install|npm run|pnpm|yarn|uv|python|pytest|codspeed|pull_request|run:" .github/workflows/codspeed.yml || trueRepository: hungpham10/codegraph-rs Length of output: 2791 🌐 Web query:
💡 Result: In actions/checkout v4, the default value for the persist-credentials input is true [1][2][3]. When set to true, the action configures the GitHub Actions authentication token (or SSH key) into the local git configuration [1][2]. This allows subsequent steps in your workflow to execute authenticated git commands without additional configuration [1][4]. The token is automatically removed during the post-job cleanup process [1][3]. If you wish to prevent this behavior—for example, to enhance security or avoid persisting credentials in the local git config—you can explicitly set persist-credentials to false in your workflow file [1][5]: - uses: actions/checkout@v4 with: persist-credentials: false While there has been community discussion regarding changing this default to false to reduce the risk of unintentional credential exposure, it remains true in the current v4 release [1][6][3]. Citations:
Sensitive Data Exposure (CWE-922) Reachability: External Disable checkout credential persistence.
Suggested change - uses: actions/checkout@v4
+ with:
+ persist-credentials: false📝 Committable suggestion
Suggested change
🧰 Tools🪛 zizmor (1.29.0)[warning] 29-29: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false (artipacked) 🤖 Prompt for AI AgentsSources: MCP tools, Linters/SAST tools |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Setup rust toolchain, cache and cargo-codspeed binary | ||||||||||||||||||||||||||||||
| uses: moonrepo/setup-rust@v0 | ||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||
| channel: stable | ||||||||||||||||||||||||||||||
| cache-target: release | ||||||||||||||||||||||||||||||
| bins: cargo-codspeed | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # Clone các repo pinned trong benches/repos/sources.txt về | ||||||||||||||||||||||||||||||
| # benches/repos/checkout/ và ghi benches/repos/list.txt. | ||||||||||||||||||||||||||||||
| - name: Fetch bench repos | ||||||||||||||||||||||||||||||
| run: bash .github/benches/fetch_repos.sh | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Build benchmark targets | ||||||||||||||||||||||||||||||
| run: cargo codspeed build -p codegraph-bench --features codspeed | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # `mode: benchmark` đẩy kết quả lên CodSpeed Cloud (auto-provision bằng OIDC) | ||||||||||||||||||||||||||||||
| # để theo dõi trend. Muốn chạy khô (không lưu baseline) thì đổi `simulation`. | ||||||||||||||||||||||||||||||
| - name: Run benchmarks | ||||||||||||||||||||||||||||||
| uses: CodSpeedHQ/action@v4 | ||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||
| mode: simulation | ||||||||||||||||||||||||||||||
| run: cargo codspeed run | ||||||||||||||||||||||||||||||
|
Comment on lines
+46
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Fix the out-of-date CodSpeed mode comment.
Suggested change- # `mode: benchmark` đẩy kết quả lên CodSpeed Cloud (auto-provision bằng OIDC)
- # để theo dõi trend. Muốn chạy khô (không lưu baseline) thì đổi `simulation`.
+ # `simulation` measures and uploads CodSpeed benchmark results.
+ # Use `walltime` only when wall-time measurements are required.📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Reject path-like repository names.
nameis trimmed but not limited to one path component. A value such as../../outsidecan escaperepos/checkout, andlist.txtcan then point the benchmark at an unexpected location. Validate the name with a safe basename allowlist before constructingdest. (raw.githubusercontent.com)Suggested validation
📝 Committable suggestion
🤖 Prompt for AI Agents