@@ -27,7 +27,7 @@ async fn create_benchmark_request_master_commits(
27
27
) -> anyhow:: Result < ( ) > {
28
28
let master_commits = & ctxt. get_master_commits ( ) . commits ;
29
29
// TODO; delete at some point in the future
30
- let cutoff: chrono:: DateTime < Utc > = chrono:: DateTime :: from_str ( "2025-06-01T00 :00:00.000Z" ) ?;
30
+ let cutoff: chrono:: DateTime < Utc > = chrono:: DateTime :: from_str ( "2025-07-24T00 :00:00.000Z" ) ?;
31
31
32
32
for master_commit in master_commits {
33
33
// We don't want to add masses of obsolete data
@@ -39,6 +39,7 @@ async fn create_benchmark_request_master_commits(
39
39
pr,
40
40
master_commit. time ,
41
41
) ;
42
+ log:: info!( "Inserting master benchmark request {benchmark:?}" ) ;
42
43
if let Err ( error) = conn. insert_benchmark_request ( & benchmark) . await {
43
44
log:: error!( "Failed to insert master benchmark request: {error:?}" ) ;
44
45
}
@@ -70,6 +71,7 @@ async fn create_benchmark_request_releases(
70
71
for ( name, date_time) in releases {
71
72
if date_time >= cutoff && !index. contains_tag ( & name) {
72
73
let release_request = BenchmarkRequest :: create_release ( & name, date_time) ;
74
+ log:: info!( "Inserting release benchmark request {release_request:?}" ) ;
73
75
if let Err ( error) = conn. insert_benchmark_request ( & release_request) . await {
74
76
log:: error!( "Failed to insert release benchmark request: {error}" ) ;
75
77
}
@@ -104,9 +106,9 @@ fn sort_benchmark_requests(index: &BenchmarkRequestIndex, request_queue: &mut [B
104
106
// just won't have a parent result available.
105
107
if level_len == 0 {
106
108
if cfg ! ( test) {
107
- panic ! ( "No commit is ready for benchmarking" ) ;
109
+ panic ! ( "No master/try commit is ready for benchmarking" ) ;
108
110
} else {
109
- log:: warn!( "No commit is ready for benchmarking" ) ;
111
+ log:: warn!( "No master/try commit is ready for benchmarking" ) ;
110
112
return ;
111
113
}
112
114
}
@@ -175,20 +177,23 @@ pub async fn build_queue(
175
177
Ok ( queue)
176
178
}
177
179
178
- /// From a benchmark_request create all the required jobs
179
- pub async fn create_benchmark_jobs (
180
+ /// Create all necessary jobs for the given benchmark request
181
+ /// and mark it as being in progress.
182
+ /// This is performed atomically, in a transaction.
183
+ pub async fn enqueue_benchmark_request (
180
184
conn : & mut dyn database:: pool:: Connection ,
181
185
benchmark_request : & BenchmarkRequest ,
182
186
) -> anyhow:: Result < ( ) > {
183
187
let mut tx = conn. transaction ( ) . await ;
184
- anyhow:: ensure!(
185
- benchmark_request. tag( ) . is_some( ) ,
186
- "Benchmark request has no tag"
187
- ) ;
188
+
189
+ let Some ( request_tag) = benchmark_request. tag ( ) else {
190
+ panic ! ( "Benchmark request {benchmark_request:?} has no tag" ) ;
191
+ } ;
192
+
193
+ log:: info!( "Enqueuing jobs for request {benchmark_request:?}" ) ;
188
194
189
195
let backends = benchmark_request. backends ( ) ?;
190
196
let profiles = benchmark_request. profiles ( ) ?;
191
- let request_tag = benchmark_request. tag ( ) . unwrap ( ) ;
192
197
193
198
// Target x benchmark_set x backend x profile -> BenchmarkJob
194
199
for target in Target :: all ( ) {
@@ -206,7 +211,7 @@ pub async fn create_benchmark_jobs(
206
211
benchmark_set as u32 ,
207
212
)
208
213
. await ?;
209
- // If there is a parent, we create a job for it to . The
214
+ // If there is a parent, we create a job for it too . The
210
215
// database will ignore it if there is already a job there.
211
216
// If the parent job has been deleted from the database
212
217
// but was already benchmarked then the collector will ignore
@@ -234,16 +239,28 @@ pub async fn create_benchmark_jobs(
234
239
Ok ( ( ) )
235
240
}
236
241
237
- /// Enqueue the job into the job_queue
238
- async fn enqueue_next_job (
242
+ /// Try to find a benchmark request that should be enqueue next, and if such request is found,
243
+ /// enqueue it.
244
+ async fn try_enqueue_next_benchmark_request (
239
245
conn : & mut dyn database:: pool:: Connection ,
240
246
index : & mut BenchmarkRequestIndex ,
241
247
) -> anyhow:: Result < ( ) > {
242
248
let queue = build_queue ( conn, index) . await ?;
249
+
243
250
for request in queue {
244
- if request. status ( ) != BenchmarkRequestStatus :: InProgress {
245
- create_benchmark_jobs ( conn, & request) . await ?;
246
- break ;
251
+ match request. status ( ) {
252
+ BenchmarkRequestStatus :: ArtifactsReady => {
253
+ enqueue_benchmark_request ( conn, & request) . await ?;
254
+ break ;
255
+ }
256
+ BenchmarkRequestStatus :: InProgress => {
257
+ // TODO: Try to mark as completed
258
+ break ;
259
+ }
260
+ BenchmarkRequestStatus :: WaitingForArtifacts
261
+ | BenchmarkRequestStatus :: Completed { .. } => {
262
+ unreachable ! ( "Unexpected request {request:?} found in request queue" ) ;
263
+ }
247
264
}
248
265
}
249
266
Ok ( ( ) )
@@ -257,7 +274,7 @@ async fn cron_enqueue_jobs(site_ctxt: &Arc<SiteCtxt>) -> anyhow::Result<()> {
257
274
create_benchmark_request_master_commits ( site_ctxt, & * conn, & index) . await ?;
258
275
// Put the releases into the `benchmark_requests` queue
259
276
create_benchmark_request_releases ( & * conn, & index) . await ?;
260
- enqueue_next_job ( & mut * conn, & mut index) . await ?;
277
+ try_enqueue_next_benchmark_request ( & mut * conn, & mut index) . await ?;
261
278
Ok ( ( ) )
262
279
}
263
280
@@ -274,8 +291,8 @@ pub async fn cron_main(site_ctxt: Arc<RwLock<Option<Arc<SiteCtxt>>>>, seconds: u
274
291
guard. as_ref ( ) . cloned ( )
275
292
} {
276
293
match cron_enqueue_jobs ( & ctxt_clone) . await {
277
- Ok ( _) => log:: info!( "Cron job executed at: {:?}" , std :: time :: SystemTime :: now ( ) ) ,
278
- Err ( e) => log:: error!( "Cron job failed to execute {}" , e ) ,
294
+ Ok ( _) => log:: info!( "Cron job finished" ) ,
295
+ Err ( e) => log:: error!( "Cron job failed to execute: {e:?}" ) ,
279
296
}
280
297
}
281
298
}
0 commit comments