-
Notifications
You must be signed in to change notification settings - Fork 78
201 lines (200 loc) · 8.15 KB
/
e2e-profiling.yaml
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#
# Copyright (C) 2019-2024 vdaas.org vald team <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: "Run E2E profiling"
on:
push:
tags:
- "*.*.*"
- "v*.*.*"
- "*.*.*-*"
- "v*.*.*-*"
pull_request:
types:
- "labeled"
env:
DATASET: fashion-mnist-784-euclidean.hdf5
jobs:
dump-contexts-to-log:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/dump-context
detect-ci-container:
if: startsWith(github.ref, 'refs/tags/') || github.event.action == 'labeled' && github.event.label.name == 'actions/e2e-profiling'
uses: ./.github/workflows/_detect-ci-container.yaml
e2e-profiling:
name: "E2E profiling"
needs: [detect-ci-container]
runs-on: ubuntu-latest
timeout-minutes: 60
container:
image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG }}
options: "--add-host host.docker.internal:host-gateway"
steps:
- uses: actions/checkout@v4
- name: Set Git config
run: |
git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: Setup E2E environment
id: setup_e2e
uses: ./.github/actions/setup-e2e
- name: Deploy Vald
id: deploy_vald
uses: ./.github/actions/e2e-deploy-vald
with:
helm_extra_options: ${{ steps.setup_e2e.outputs.HELM_EXTRA_OPTIONS }}
values: .github/helm/values/values-profile.yaml
wait_for_selector: app=vald-lb-gateway
- name: Deploy profefe
shell: bash
run: |
make k8s/metrics/profefe/deploy
kubectl patch cronjob kprofefe -p '{"spec": {"schedule": "*/1 * * * *"}}'
kubectl wait --for=condition=ready pod -l app=profefe --timeout=300s
- name: Run E2E CRUD
continue-on-error: true
shell: bash
run: |
make hack/benchmark/assets/dataset/${{ env.DATASET }}
make E2E_BIND_PORT=8081 \
E2E_DATASET_NAME=${{ env.DATASET }} \
E2E_INSERT_COUNT=10000 \
E2E_SEARCH_COUNT=100 \
E2E_SEARCH_BY_ID_COUNT=100 \
E2E_GET_OBJECT_COUNT=100 \
E2E_UPDATE_COUNT=100 \
E2E_UPSERT_COUNT=100 \
E2E_REMOVE_COUNT=100 \
E2E_WAIT_FOR_CREATE_INDEX_DURATION=3m \
E2E_TARGET_POD_NAME=${POD_NAME} \
E2E_TARGET_NAMESPACE=default \
e2e
env:
POD_NAME: ${{ steps.deploy_vald.outputs.POD_NAME }}
- name: Get profiles
shell: bash
run: |
mkdir -p profiles
kubectl port-forward deployment/profefe 10100:10100 &
sleep 3
for svc in vald-agent-ngt vald-lb-gateway vald-discoverer vald-manager-index
do
for t in heap cpu goroutine threadcreate
do
curl "http://localhost:10100/api/0/profiles/merge?service=${svc}&type=${t}&from=2021-07-01T00:00:00&to=2030-07-01T00:00:00" \
--output profiles/${svc}-${t}.pb
done
done
- uses: actions/upload-artifact@v4
with:
name: profiles
path: profiles/*
- uses: actions/cache@v4
id: cache
with:
path: ./profiles-main
key: ${{ runner.os }}-profiles-main-${{ github.sha }}
restore-keys: ${{ runner.os }}-profiles-main-
- name: Update cache
if: startsWith(github.ref, 'refs/tags/')
run: |
mkdir -p profiles-main
cp -f profiles/* profiles-main/
cp -f versions/VALD_VERSION profiles-main/
- name: Generate graphs
shell: bash
run: |
tag="unknown"
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
tag="pr-${{ github.event.pull_request.number }}"
elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
tag="main-${{ github.sha }}"
elif [[ "${{ github.ref }}" == "refs/heads/release/*" ]]; then
version=$(echo ${{ github.ref }} | sed 's/refs\/heads\/release\///')
tag="v${version}-${{ github.sha }}"
elif [[ -f profiles-main/VALD_VERSION && -s profiles-main/VALD_VERSION ]]; then
tag=$(cat profiles-main/VALD_VERSION)
fi
mkdir -p graphs
for svc in vald-agent-ngt vald-lb-gateway vald-discoverer vald-manager-index
do
for t in heap cpu goroutine threadcreate
do
echo "generating: graphs/${svc}-${t}-${GITHUB_SHA::6}.svg"
go tool pprof --svg profiles/${svc}-${t}.pb > graphs/${svc}-${t}-${GITHUB_SHA::6}.svg
echo "generating: graphs/${svc}-${t}-${GITHUB_SHA::6}.png"
go tool pprof --png profiles/${svc}-${t}.pb > graphs/${svc}-${t}-${GITHUB_SHA::6}.png
if [ -f profiles-main/${svc}-${t}.pb ]; then
echo "generating: graphs/${svc}-${t}-main-${GITHUB_SHA::6}.svg"
go tool pprof --svg -base=profiles-main/${svc}-${t}.pb profiles/${svc}-${t}.pb > graphs/${svc}-${t}-diff-${tag}-${GITHUB_SHA::6}.svg
echo "generating: graphs/${svc}-${t}-main-${GITHUB_SHA::6}.png"
go tool pprof --png -base=profiles-main/${svc}-${t}.pb profiles/${svc}-${t}.pb > graphs/${svc}-${t}-diff-${tag}-${GITHUB_SHA::6}.png
else
echo "skipping: profiles-main/${svc}-${t}.pb does not exist."
fi
done
done
- uses: actions/upload-artifact@v4
with:
name: graphs
path: graphs/*
- name: Upload to vald-ci-images repository
if: github.event.action == 'labeled' && github.event.label.name == 'actions/e2e-profiling'
shell: bash
run: |
CLONE_DIR=$(mktemp -d)
git clone --depth 1 https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/vdaas-ci/vald-ci-images.git $CLONE_DIR
cp -r graphs $CLONE_DIR/${GITHUB_SHA::6}
cd $CLONE_DIR
git config user.email "[email protected]"
git config user.name "vdaas-ci"
git add .
git commit -m ":robot: Add ${GITHUB_SHA::6}"
git push https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/vdaas-ci/vald-ci-images.git --set-upstream main
env:
GITHUB_USER: ${{ secrets.DISPATCH_USER }}
GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
- name: Comment
if: github.event.action == 'labeled' && github.event.label.name == 'actions/e2e-profiling'
shell: bash
run: |
base="https://raw.githubusercontent.com/vdaas-ci/vald-ci-images/main/${GITHUB_SHA::6}"
body="<table><tr><th>type</th>"
for svc in vald-agent-ngt vald-lb-gateway vald-discoverer vald-manager-index
do
body="$body<th>$svc</th>"
done
body="$body</tr>"
for t in cpu heap
do
body="$body<tr><td>${t}</td>"
for svc in vald-agent-ngt vald-lb-gateway vald-discoverer vald-manager-index
do
body="$body<td><img src=\\\"$base/${svc}-${t}-${GITHUB_SHA::6}.png\\\" width=\\\"100%\\\"></td>"
done
body="$body</tr>"
done
body="$body</table>"
curl --include --verbose --fail \
-H "Accept: application/json" \
-H "Content-Type:application/json" \
-H "Authorization: token ${GITHUB_TOKEN}" \
--request POST \
--data "{\"body\": \"# Profile Report\n$body\n<a href=\\\"https://github.com/vdaas-ci/vald-ci-images/tree/main/${GITHUB_SHA::6}\\\">other images</a>\"}" \
$API_URL
env:
GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
API_URL: ${{ github.event.pull_request.comments_url }}