Skip to content

Commit 9e8ac65

Browse files
Merge pull request #705 from Mark-Simulacrum/cleanup
Various small cleanups
2 parents 1575ef4 + 8129d0d commit 9e8ac65

File tree

10 files changed

+26
-273
lines changed

10 files changed

+26
-273
lines changed

Cargo.lock

Lines changed: 0 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

collector/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ semver = "0.9"
2020
reqwest = { version = "0.10", features = ["json"] }
2121
xz2 = "0.1.3"
2222
tar = "0.4"
23-
crossbeam-channel = "0.4.2"
2423
tokio = { version = "0.2", features = ["rt-core"] }
2524
rustc-artifacts = "0.2"
2625
database = { path = "../database" }

collector/src/api.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,3 @@
1-
pub mod collected {
2-
use crate::Commit;
3-
4-
#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize)]
5-
pub enum Request {
6-
// Will benchmark commit with these benchmarks
7-
BenchmarkCommit {
8-
commit: Commit,
9-
// crate name
10-
benchmarks: Vec<String>,
11-
},
12-
// benchmark finished for this benchmark/commit
13-
BenchmarkDone {
14-
// crate name
15-
benchmark: String,
16-
commit: Commit,
17-
},
18-
}
19-
20-
#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize)]
21-
pub struct Response {
22-
// nothing
23-
}
24-
}
25-
261
pub mod next_commit {
272
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
283
pub struct Response {

collector/src/background_worker.rs

Lines changed: 0 additions & 59 deletions
This file was deleted.

collector/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use chrono::NaiveDate;
2-
pub use database::{Commit, PatchName, QueryLabel, Sha};
2+
pub use database::{Commit, PatchName, QueryLabel};
33
use serde::Deserialize;
44
use std::cmp::PartialOrd;
55
use std::fmt;

collector/src/main.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
extern crate clap;
55

66
use anyhow::{bail, Context};
7-
use collector::api::collected;
87
use database::{pool::Connection, ArtifactId, Commit};
98
use log::debug;
109
use std::collections::HashSet;
@@ -16,11 +15,9 @@ use std::process::Command;
1615
use std::{str, time::Instant};
1716
use tokio::runtime::Runtime;
1817

19-
mod background_worker;
2018
mod execute;
2119
mod sysroot;
2220

23-
use background_worker::send_home;
2421
use execute::{Benchmark, Profiler};
2522
use sysroot::Sysroot;
2623

@@ -195,21 +192,11 @@ fn bench(
195192
compiler: Compiler<'_>,
196193
benchmarks: &[Benchmark],
197194
iterations: usize,
198-
call_home: bool,
199195
self_profile: bool,
200196
) -> BenchmarkErrors {
201197
let mut errors = BenchmarkErrors::new();
202198
eprintln!("Benchmarking {} for triple {}", cid, compiler.triple);
203199

204-
if call_home {
205-
if let ArtifactId::Commit(commit) = cid {
206-
send_home(collected::Request::BenchmarkCommit {
207-
commit: commit.clone(),
208-
benchmarks: benchmarks.iter().map(|b| b.name.to_string()).collect(),
209-
});
210-
}
211-
}
212-
213200
let has_measureme = Command::new("summarize").output().is_ok();
214201
if self_profile {
215202
assert!(
@@ -267,15 +254,6 @@ fn bench(
267254
&format!("{:?}", s),
268255
));
269256
};
270-
271-
if call_home {
272-
if let ArtifactId::Commit(commit) = cid {
273-
send_home(collected::Request::BenchmarkDone {
274-
benchmark: benchmark.name.to_string(),
275-
commit: commit.clone(),
276-
});
277-
}
278-
}
279257
}
280258
let end = start.elapsed();
281259

@@ -559,7 +537,6 @@ fn main_result() -> anyhow::Result<i32> {
559537
},
560538
&benchmarks,
561539
1,
562-
/* call_home */ false,
563540
self_profile,
564541
);
565542
res.fail_if_nonzero()?;
@@ -606,7 +583,6 @@ fn main_result() -> anyhow::Result<i32> {
606583
Compiler::from_sysroot(&sysroot),
607584
&benchmarks,
608585
3,
609-
/* call_home */ true,
610586
self_profile,
611587
);
612588

@@ -684,7 +660,6 @@ fn main_result() -> anyhow::Result<i32> {
684660
},
685661
&benchmarks,
686662
3,
687-
/* call_home */ false,
688663
/* self_profile */ false,
689664
);
690665
res.fail_if_nonzero()?;
@@ -768,7 +743,6 @@ fn main_result() -> anyhow::Result<i32> {
768743
Ok(2)
769744
}
770745
};
771-
background_worker::shut_down();
772746
ret
773747
}
774748

database/src/lib.rs

Lines changed: 3 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -141,106 +141,9 @@ impl<'de> Deserialize<'de> for Date {
141141
}
142142
}
143143

144-
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
145-
pub enum Sha {
146-
/// Straight-up bytes of the 40-long hex-encoded sha
147-
Hex([u8; 20]),
148-
/// Usually a string ID provided by the user.
149-
Raw(RawSha),
150-
}
151-
152-
intern!(pub struct RawSha);
153-
154-
impl PartialEq<str> for Sha {
155-
fn eq(&self, other: &str) -> bool {
156-
self.to_string() == other
157-
}
158-
}
159-
160-
fn hex_decode(s: &str) -> Option<[u8; 20]> {
161-
let mut in_progress = 0;
162-
let mut v = [0; 20];
163-
for (idx, ch) in s.chars().enumerate() {
164-
let offset = if idx % 2 == 0 { 4 } else { 0 };
165-
in_progress |= (ch.to_digit(16)? as u8) << offset;
166-
if idx % 2 != 0 {
167-
v[idx / 2] = in_progress;
168-
in_progress = 0;
169-
}
170-
}
171-
Some(v)
172-
}
173-
174-
impl<'a> From<&'a str> for Sha {
175-
fn from(s: &'a str) -> Sha {
176-
if let Some(v) = hex_decode(s) {
177-
return Sha::Hex(v);
178-
}
179-
180-
Sha::Raw(s.into())
181-
}
182-
}
183-
184-
impl Serialize for Sha {
185-
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
186-
where
187-
S: serde::ser::Serializer,
188-
{
189-
serializer.collect_str(&self)
190-
}
191-
}
192-
193-
impl<'de> Deserialize<'de> for Sha {
194-
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
195-
where
196-
D: serde::de::Deserializer<'de>,
197-
{
198-
use serde::de::Visitor;
199-
struct ShaVisitor;
200-
impl<'de> Visitor<'de> for ShaVisitor {
201-
type Value = Sha;
202-
203-
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
204-
f.write_str("a string")
205-
}
206-
207-
fn visit_str<E>(self, s: &str) -> Result<Sha, E> {
208-
Ok(s.into())
209-
}
210-
211-
fn visit_borrowed_str<E>(self, s: &'de str) -> Result<Sha, E> {
212-
Ok(s.into())
213-
}
214-
}
215-
deserializer.deserialize_str(ShaVisitor)
216-
}
217-
}
218-
219-
impl fmt::Debug for Sha {
220-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
221-
write!(f, "{}", self)
222-
}
223-
}
224-
225-
impl fmt::Display for Sha {
226-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
227-
match *self {
228-
Sha::Hex(hex) => {
229-
for &b in hex.iter() {
230-
write!(f, "{:x}{:x}", b >> 4, b & 0xf)?;
231-
}
232-
}
233-
Sha::Raw(raw) => {
234-
write!(f, "{}", raw)?;
235-
}
236-
}
237-
Ok(())
238-
}
239-
}
240-
241-
#[derive(Debug, Copy, Clone, serde::Deserialize, serde::Serialize)]
144+
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
242145
pub struct Commit {
243-
pub sha: Sha,
146+
pub sha: String,
244147
pub date: Date,
245148
}
246149

@@ -709,7 +612,7 @@ impl Index {
709612
}
710613

711614
pub fn commits(&self) -> Vec<Commit> {
712-
let mut commits = self.commits.map.keys().copied().collect::<Vec<_>>();
615+
let mut commits = self.commits.map.keys().cloned().collect::<Vec<_>>();
713616
commits.sort();
714617
commits
715618
}

site/src/api.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub mod data {
108108
}
109109

110110
pub mod graph {
111-
use collector::{Bound, Sha};
111+
use collector::Bound;
112112
use serde::{Deserialize, Serialize};
113113
use std::collections::HashMap;
114114

@@ -135,7 +135,7 @@ pub mod graph {
135135
pub benchmarks: HashMap<String, HashMap<String, Vec<(String, Vec<GraphData>)>>>,
136136
pub max: HashMap<String, f32>,
137137
pub colors: Vec<String>,
138-
pub commits: Vec<Sha>,
138+
pub commits: Vec<String>,
139139
}
140140
}
141141

0 commit comments

Comments
 (0)