Skip to content

Commit 0db7349

Browse files
authored
Merge pull request #1804 from Kobzol/artifact-size-fix
Restore adding binary size metrics into DB
2 parents 74e5546 + 9fcaa54 commit 0db7349

File tree

3 files changed

+72
-17
lines changed

3 files changed

+72
-17
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -360,22 +360,24 @@ jobs:
360360

361361
- name: Gather data
362362
run: |
363-
cargo run --bin collector bench_local `which rustc` --include syn --id version1 --db postgresql://postgres:[email protected]:5432/postgres
364-
cargo run --bin collector bench_local `rustup +nightly which rustc` --include syn --id version2 --db postgresql://postgres:[email protected]:5432/postgres
363+
cargo run --bin collector bench_local `which rustc` --include syn --id version1 \
364+
--self-profile \
365+
--db postgresql://postgres:[email protected]:5432/postgres
366+
cargo run --bin collector bench_local `rustup +nightly which rustc` --include syn --id version2 \
367+
--self-profile \
368+
--db postgresql://postgres:[email protected]:5432/postgres
365369
366370
- name: Build site
367371
run: cargo build --bin site
368372

373+
- name: Setup Python
374+
uses: actions/setup-python@v5
375+
376+
- name: Install Python dependencies
377+
run: python3 -m pip install msgpack requests
378+
369379
# Check that data from the /get endpoint can be successfully queried.
370380
- name: Query compare page data
371381
run: |
372382
DATABASE_URL=postgresql://postgres:[email protected]:5432/postgres cargo run --bin site &
373-
curl http://localhost:2346/perf/get \
374-
-H 'Content-Type:application/json' \
375-
-d '{"start": "version1", "end": "version2", "stat": "instructions:u" }' \
376-
--output out.msgpack \
377-
--retry-connrefused \
378-
--connect-timeout 5 \
379-
--max-time 10 \
380-
--retry 3 \
381-
--retry-delay 5
383+
python3 ci/check-site.py version1 version2

ci/check-site.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""
2+
Checks that the perf site running locally returns non-empty data for a set of artifacts.
3+
"""
4+
import sys
5+
import time
6+
7+
import msgpack
8+
import requests
9+
10+
if __name__ == "__main__":
11+
if len(sys.argv) < 3:
12+
print("Usage: python3 check-site.py <version1> <version2>")
13+
exit(1)
14+
version1 = sys.argv[1]
15+
version2 = sys.argv[2]
16+
17+
# Wait for the site to start
18+
while True:
19+
try:
20+
response = requests.post("http://localhost:2346/perf/get", json={
21+
"start": version1,
22+
"end": version2,
23+
"stat": "instructions:u"
24+
})
25+
if response.content != b"no data yet, please wait":
26+
break
27+
except BaseException as e:
28+
print(e)
29+
30+
print(f"Site not online yet, waiting")
31+
time.sleep(1)
32+
33+
# instructions:u is not available on CI, so check at least wall time and binary size
34+
stats = ("wall-time", "size:linked_artifact")
35+
for stat in stats:
36+
print(f"Checking {stat}")
37+
response = requests.post("http://localhost:2346/perf/get", json={
38+
"start": version1,
39+
"end": version2,
40+
"stat": stat
41+
})
42+
if response.status_code != 200:
43+
raise Exception(f"Failure {response.status_code}: {response.content}")
44+
payload = msgpack.unpackb(response.content)
45+
print(payload)
46+
for artifact_id in ("a", "b"):
47+
artifact = payload[artifact_id]
48+
assert artifact["component_sizes"].get("librustc_driver", 0) > 0
49+
comparisons = payload["compile_comparisons"]
50+
assert len(comparisons) > 0

collector/src/compile/execute/bencher.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,21 +184,24 @@ impl<'a> Processor for BenchProcessor<'a> {
184184
let version = get_rustc_perf_commit();
185185
let collection = self.conn.collection_id(&version).await;
186186

187-
// If the gathered metrics were produced with self profile enabled, then they
188-
// are not realistic. Do not store the metrics into the DB for self-profile
189-
// runs to avoid unnecessary DB storage.
190187
if let Some(files) = res.2 {
191188
self.self_profiles.push(RecordedSelfProfile {
192189
collection,
193190
scenario,
194191
profile,
195192
files,
196193
});
197-
} else {
198-
self.insert_stats(collection, scenario, profile, data.backend, res.0)
199-
.await;
194+
195+
// If the gathered metrics were produced with self profile enabled, then they
196+
// are not realistic. Do not store the metrics that are affected by
197+
// self-profiling into the DB for self-profile runs to avoid unnecessary
198+
// DB storage.
199+
res.0.stats.retain(|key, _| key.starts_with("size:"));
200200
}
201201

202+
self.insert_stats(collection, scenario, profile, data.backend, res.0)
203+
.await;
204+
202205
Ok(Retry::No)
203206
}
204207
Err(DeserializeStatError::NoOutput(output)) => {

0 commit comments

Comments
 (0)