Repository navigation
90 lines (77 loc) · 2.91 KB
/
Copy pathmemory-bench.yml
File metadata and controls
90 lines (77 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Memory benchmark
on:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
env:
CARGO_TERM_COLOR: always
jobs:
bench:
name: memory before vs after
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Check out base
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.pull_request.base.sha }}
path: base
- uses: dtolnay/rust-toolchain@39008827e6b4319a349e9a42dfc90579dd25f1ca # stable
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
key: memory-bench
- name: Cache models
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: models
key: fastembed-models-nomic-v1
# Both builds share one target dir so dependencies compile once.
- name: Build base and head
run: |
mkdir -p bin
cargo build --release --manifest-path base/Cargo.toml --target-dir target --bin embedding
cp target/release/embedding bin/base
cargo build --release --bins --example bench_memory
cp target/release/embedding bin/head
- name: Download model
run: target/release/warmup
env:
EMBEDDING_MODELS: nomic
EMBEDDING_CACHE_DIR: ${{ github.workspace }}/models
- name: Run benchmark
run: |
target/release/examples/bench_memory \
--base bin/base --head bin/head \
--cache-dir "$GITHUB_WORKSPACE/models" \
--out bench.md
{
echo "<!-- memory-bench -->"
echo "### Memory benchmark"
echo
echo "Base \`${BASE_SHA:0:7}\` vs head \`${HEAD_SHA:0:7}\` on \`ubuntu-latest\`."
echo
cat bench.md
} > comment.md
cat comment.md >> "$GITHUB_STEP_SUMMARY"
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
# Fork PRs get a read-only token, so they only get the job summary.
- name: Comment on PR
if: github.event.pull_request.head.repo.full_name == github.repository
run: |
id=$(gh api "repos/$REPO/issues/$PR/comments" --paginate \
-q '.[] | select(.body | startswith("<!-- memory-bench -->")) | .id' | head -n1)
if [ -n "$id" ]; then
gh api -X PATCH "repos/$REPO/issues/comments/$id" -F body=@comment.md > /dev/null
else
gh pr comment "$PR" --repo "$REPO" --body-file comment.md
fi
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
PR: ${{ github.event.pull_request.number }}