@@ -27,7 +27,7 @@ async fn create_benchmark_request_master_commits(
2727) -> anyhow:: Result < ( ) > {
2828 let master_commits = & ctxt. get_master_commits ( ) . commits ;
2929 // 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" ) ?;
3131
3232 for master_commit in master_commits {
3333 // We don't want to add masses of obsolete data
@@ -39,6 +39,7 @@ async fn create_benchmark_request_master_commits(
3939 pr,
4040 master_commit. time ,
4141 ) ;
42+ log:: info!( "Inserting master benchmark request {benchmark:?}" ) ;
4243 if let Err ( error) = conn. insert_benchmark_request ( & benchmark) . await {
4344 log:: error!( "Failed to insert master benchmark request: {error:?}" ) ;
4445 }
@@ -70,6 +71,7 @@ async fn create_benchmark_request_releases(
7071 for ( name, date_time) in releases {
7172 if date_time >= cutoff && !index. contains_tag ( & name) {
7273 let release_request = BenchmarkRequest :: create_release ( & name, date_time) ;
74+ log:: info!( "Inserting release benchmark request {release_request:?}" ) ;
7375 if let Err ( error) = conn. insert_benchmark_request ( & release_request) . await {
7476 log:: error!( "Failed to insert release benchmark request: {error}" ) ;
7577 }
@@ -104,9 +106,9 @@ fn sort_benchmark_requests(index: &BenchmarkRequestIndex, request_queue: &mut [B
104106 // just won't have a parent result available.
105107 if level_len == 0 {
106108 if cfg ! ( test) {
107- panic ! ( "No commit is ready for benchmarking" ) ;
109+ panic ! ( "No master/try commit is ready for benchmarking" ) ;
108110 } else {
109- log:: warn!( "No commit is ready for benchmarking" ) ;
111+ log:: warn!( "No master/try commit is ready for benchmarking" ) ;
110112 return ;
111113 }
112114 }
@@ -175,20 +177,23 @@ pub async fn build_queue(
175177 Ok ( queue)
176178}
177179
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 (
180184 conn : & mut dyn database:: pool:: Connection ,
181185 benchmark_request : & BenchmarkRequest ,
182186) -> anyhow:: Result < ( ) > {
183187 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:?}" ) ;
188194
189195 let backends = benchmark_request. backends ( ) ?;
190196 let profiles = benchmark_request. profiles ( ) ?;
191- let request_tag = benchmark_request. tag ( ) . unwrap ( ) ;
192197
193198 // Target x benchmark_set x backend x profile -> BenchmarkJob
194199 for target in Target :: all ( ) {
@@ -206,7 +211,7 @@ pub async fn create_benchmark_jobs(
206211 benchmark_set as u32 ,
207212 )
208213 . 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
210215 // database will ignore it if there is already a job there.
211216 // If the parent job has been deleted from the database
212217 // but was already benchmarked then the collector will ignore
@@ -234,16 +239,28 @@ pub async fn create_benchmark_jobs(
234239 Ok ( ( ) )
235240}
236241
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 (
239245 conn : & mut dyn database:: pool:: Connection ,
240246 index : & mut BenchmarkRequestIndex ,
241247) -> anyhow:: Result < ( ) > {
242248 let queue = build_queue ( conn, index) . await ?;
249+
243250 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+ }
247264 }
248265 }
249266 Ok ( ( ) )
@@ -257,7 +274,7 @@ async fn cron_enqueue_jobs(site_ctxt: &Arc<SiteCtxt>) -> anyhow::Result<()> {
257274 create_benchmark_request_master_commits ( site_ctxt, & * conn, & index) . await ?;
258275 // Put the releases into the `benchmark_requests` queue
259276 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 ?;
261278 Ok ( ( ) )
262279}
263280
@@ -274,8 +291,8 @@ pub async fn cron_main(site_ctxt: Arc<RwLock<Option<Arc<SiteCtxt>>>>, seconds: u
274291 guard. as_ref ( ) . cloned ( )
275292 } {
276293 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:?}" ) ,
279296 }
280297 }
281298 }
0 commit comments