Skip to content

Commit b8aec2d

Browse files
committed
Pass Target and BenchmarkSet by value
1 parent 4ff7c62 commit b8aec2d

File tree

6 files changed

+43
-43
lines changed

6 files changed

+43
-43
lines changed

collector/src/bin/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ Make sure to modify `{dir}/perf-config.json` if the category/artifact don't matc
13281328
let target = database::Target::from_str(&target).map_err(|e| anyhow::anyhow!(e))?;
13291329
rt.block_on(conn.add_collector_config(
13301330
&collector_name,
1331-
&target,
1331+
target,
13321332
benchmark_set,
13331333
is_active,
13341334
))?;

database/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,12 +1181,12 @@ impl CollectorConfig {
11811181
&self.name
11821182
}
11831183

1184-
pub fn target(&self) -> &Target {
1185-
&self.target
1184+
pub fn target(&self) -> Target {
1185+
self.target
11861186
}
11871187

1188-
pub fn benchmark_set(&self) -> &BenchmarkSet {
1189-
&self.benchmark_set
1188+
pub fn benchmark_set(&self) -> BenchmarkSet {
1189+
self.benchmark_set
11901190
}
11911191

11921192
pub fn is_active(&self) -> bool {

database/src/pool.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ pub trait Connection: Send + Sync {
217217
async fn enqueue_benchmark_job(
218218
&self,
219219
request_tag: &str,
220-
target: &Target,
221-
backend: &CodegenBackend,
222-
profile: &Profile,
220+
target: Target,
221+
backend: CodegenBackend,
222+
profile: Profile,
223223
benchmark_set: u32,
224224
) -> anyhow::Result<()>;
225225

@@ -238,7 +238,7 @@ pub trait Connection: Send + Sync {
238238
async fn add_collector_config(
239239
&self,
240240
collector_name: &str,
241-
target: &Target,
241+
target: Target,
242242
benchmark_set: u32,
243243
is_active: bool,
244244
) -> anyhow::Result<CollectorConfig>;
@@ -253,8 +253,8 @@ pub trait Connection: Send + Sync {
253253
async fn dequeue_benchmark_job(
254254
&self,
255255
collector_name: &str,
256-
target: &Target,
257-
benchmark_set: &BenchmarkSet,
256+
target: Target,
257+
benchmark_set: BenchmarkSet,
258258
) -> anyhow::Result<Option<BenchmarkJob>>;
259259

260260
/// Try and mark the benchmark_request as completed. Will return `true` if
@@ -701,9 +701,9 @@ mod tests {
701701
let result = db
702702
.enqueue_benchmark_job(
703703
benchmark_request.tag().unwrap(),
704-
&Target::X86_64UnknownLinuxGnu,
705-
&CodegenBackend::Llvm,
706-
&Profile::Opt,
704+
Target::X86_64UnknownLinuxGnu,
705+
CodegenBackend::Llvm,
706+
Profile::Opt,
707707
0u32,
708708
)
709709
.await;
@@ -793,7 +793,7 @@ mod tests {
793793
let db = ctx.db_client().connection().await;
794794

795795
let inserted_config = db
796-
.add_collector_config("collector-1", &Target::X86_64UnknownLinuxGnu, 1, true)
796+
.add_collector_config("collector-1", Target::X86_64UnknownLinuxGnu, 1, true)
797797
.await
798798
.unwrap();
799799

@@ -819,8 +819,8 @@ mod tests {
819819
let benchmark_job_result = db
820820
.dequeue_benchmark_job(
821821
"collector-1",
822-
&Target::X86_64UnknownLinuxGnu,
823-
&BenchmarkSet(420),
822+
Target::X86_64UnknownLinuxGnu,
823+
BenchmarkSet(420),
824824
)
825825
.await;
826826

@@ -839,7 +839,7 @@ mod tests {
839839
let time = chrono::DateTime::from_str("2021-09-01T00:00:00.000Z").unwrap();
840840

841841
let insert_result = db
842-
.add_collector_config("collector-1", &Target::X86_64UnknownLinuxGnu, 1, true)
842+
.add_collector_config("collector-1", Target::X86_64UnknownLinuxGnu, 1, true)
843843
.await;
844844
assert!(insert_result.is_ok());
845845

@@ -857,9 +857,9 @@ mod tests {
857857
let enqueue_result = db
858858
.enqueue_benchmark_job(
859859
benchmark_request.tag().unwrap(),
860-
&Target::X86_64UnknownLinuxGnu,
861-
&CodegenBackend::Llvm,
862-
&Profile::Opt,
860+
Target::X86_64UnknownLinuxGnu,
861+
CodegenBackend::Llvm,
862+
Profile::Opt,
863863
1u32,
864864
)
865865
.await;
@@ -886,7 +886,7 @@ mod tests {
886886
);
887887
assert_eq!(
888888
benchmark_job.benchmark_set(),
889-
*collector_config.benchmark_set()
889+
collector_config.benchmark_set()
890890
);
891891
assert_eq!(
892892
benchmark_job.collector_name().unwrap(),

database/src/pool/postgres.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,9 +1676,9 @@ where
16761676
async fn enqueue_benchmark_job(
16771677
&self,
16781678
request_tag: &str,
1679-
target: &Target,
1680-
backend: &CodegenBackend,
1681-
profile: &Profile,
1679+
target: Target,
1680+
backend: CodegenBackend,
1681+
profile: Profile,
16821682
benchmark_set: u32,
16831683
) -> anyhow::Result<()> {
16841684
self.conn()
@@ -1736,7 +1736,7 @@ where
17361736
async fn add_collector_config(
17371737
&self,
17381738
collector_name: &str,
1739-
target: &Target,
1739+
target: Target,
17401740
benchmark_set: u32,
17411741
is_active: bool,
17421742
) -> anyhow::Result<CollectorConfig> {
@@ -1774,7 +1774,7 @@ where
17741774

17751775
let collector_config = CollectorConfig {
17761776
name: collector_name.into(),
1777-
target: *target,
1777+
target,
17781778
benchmark_set: BenchmarkSet(benchmark_set),
17791779
is_active,
17801780
last_heartbeat_at: row.get::<_, DateTime<Utc>>(0),
@@ -1822,8 +1822,8 @@ where
18221822
async fn dequeue_benchmark_job(
18231823
&self,
18241824
collector_name: &str,
1825-
target: &Target,
1826-
benchmark_set: &BenchmarkSet,
1825+
target: Target,
1826+
benchmark_set: BenchmarkSet,
18271827
) -> anyhow::Result<Option<BenchmarkJob>> {
18281828
// We take the oldest job from the job_queue matching the benchmark_set,
18291829
// target and status of 'queued'
@@ -1883,10 +1883,10 @@ where
18831883
Some(row) => {
18841884
let job = BenchmarkJob {
18851885
id: row.get::<_, i32>(0) as u32,
1886-
target: *target,
1887-
backend: CodegenBackend::from_str(&row.get::<_, String>(1))
1886+
target,
1887+
backend: CodegenBackend::from_str(&row.get::<_, &str>(1))
18881888
.map_err(|e| anyhow::anyhow!(e))?,
1889-
profile: Profile::from_str(&row.get::<_, String>(2))
1889+
profile: Profile::from_str(&row.get::<_, &str>(2))
18901890
.map_err(|e| anyhow::anyhow!(e))?,
18911891
request_tag: row.get::<_, String>(3),
18921892
benchmark_set: benchmark_set.clone(),
@@ -1965,7 +1965,7 @@ where
19651965
.execute(
19661966
"
19671967
UPDATE
1968-
job_queue
1968+
job_queue
19691969
SET
19701970
status = $1,
19711971
completed_at = NOW()

database/src/pool/sqlite.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,9 +1296,9 @@ impl Connection for SqliteConnection {
12961296
async fn enqueue_benchmark_job(
12971297
&self,
12981298
_request_tag: &str,
1299-
_target: &Target,
1300-
_backend: &CodegenBackend,
1301-
_profile: &Profile,
1299+
_target: Target,
1300+
_backend: CodegenBackend,
1301+
_profile: Profile,
13021302
_benchmark_set: u32,
13031303
) -> anyhow::Result<()> {
13041304
no_queue_implementation_abort!()
@@ -1341,16 +1341,16 @@ impl Connection for SqliteConnection {
13411341
async fn dequeue_benchmark_job(
13421342
&self,
13431343
_collector_name: &str,
1344-
_target: &Target,
1345-
_benchmark_set: &BenchmarkSet,
1344+
_target: Target,
1345+
_benchmark_set: BenchmarkSet,
13461346
) -> anyhow::Result<Option<BenchmarkJob>> {
13471347
no_queue_implementation_abort!()
13481348
}
13491349

13501350
async fn add_collector_config(
13511351
&self,
13521352
_collector_name: &str,
1353-
_target: &Target,
1353+
_target: Target,
13541354
_benchmark_set: u32,
13551355
_is_active: bool,
13561356
) -> anyhow::Result<CollectorConfig> {

site/src/job_queue/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,12 @@ pub async fn enqueue_benchmark_request(
198198
// Target x benchmark_set x backend x profile -> BenchmarkJob
199199
for target in Target::all() {
200200
for benchmark_set in 0..benchmark_set_count(target.into()) {
201-
for backend in backends.iter() {
202-
for profile in profiles.iter() {
201+
for &backend in backends.iter() {
202+
for &profile in profiles.iter() {
203203
tx.conn()
204204
.enqueue_benchmark_job(
205205
request_tag,
206-
&target,
206+
target,
207207
backend,
208208
profile,
209209
benchmark_set as u32,
@@ -218,7 +218,7 @@ pub async fn enqueue_benchmark_request(
218218
tx.conn()
219219
.enqueue_benchmark_job(
220220
parent_sha,
221-
&target,
221+
target,
222222
backend,
223223
profile,
224224
benchmark_set as u32,

0 commit comments

Comments
 (0)