@@ -40,9 +40,6 @@ use super::{
40
40
resmoke_config_writer:: ResmokeConfigActor ,
41
41
} ;
42
42
43
- /// Required number of tests needing stats to use historic data for task splitting.
44
- const REQUIRED_STATS_THRESHOLD : f32 = 0.8 ;
45
-
46
43
/// Parameters describing how a specific resmoke suite should be generated.
47
44
#[ derive( Clone , Debug , Default ) ]
48
45
pub struct ResmokeGenParams {
@@ -385,20 +382,6 @@ impl GenResmokeTaskServiceImpl {
385
382
}
386
383
}
387
384
388
- /// Calculate the number of tests that fit in the given percent.
389
- ///
390
- /// # Arguments
391
- ///
392
- /// * `n_tests` - Total number of tests.
393
- /// * `percent` - Percentage to calculate.
394
- ///
395
- /// # Returns
396
- ///
397
- /// Number of tests that fit in the given percentage.
398
- fn percent_of_tests ( n_tests : usize , percent : f32 ) -> usize {
399
- ( n_tests as f32 * percent) as usize
400
- }
401
-
402
385
impl GenResmokeTaskServiceImpl {
403
386
/// Split the given task into a number of sub-tasks for parallel execution.
404
387
///
@@ -421,18 +404,6 @@ impl GenResmokeTaskServiceImpl {
421
404
) -> Result < Vec < SubSuite > > {
422
405
let origin_suite = multiversion_name. unwrap_or ( & params. suite_name ) ;
423
406
let test_list = self . get_test_list ( params, multiversion_name) ?;
424
- let required_stats_count = percent_of_tests ( test_list. len ( ) , REQUIRED_STATS_THRESHOLD ) ;
425
- if task_stats. test_map . len ( ) < required_stats_count {
426
- event ! (
427
- Level :: WARN ,
428
- "Incomplete runtime stats for {}, using fallback, stat_count={}, test_count={}, limit={}" ,
429
- & params. suite_name,
430
- task_stats. test_map. len( ) ,
431
- test_list. len( ) ,
432
- required_stats_count
433
- ) ;
434
- return self . split_task_fallback ( params, multiversion_name, multiversion_tags) ;
435
- }
436
407
let total_runtime = task_stats
437
408
. test_map
438
409
. iter ( )
@@ -451,20 +422,22 @@ impl GenResmokeTaskServiceImpl {
451
422
let sorted_test_list = sort_tests_by_runtime ( test_list, task_stats) ;
452
423
let mut running_tests = vec ! [ vec![ ] ; max_tasks] ;
453
424
let mut running_runtimes = vec ! [ 0.0 ; max_tasks] ;
425
+ let mut left_tests = vec ! [ ] ;
454
426
455
427
for test in sorted_test_list {
456
- let mut min_idx = 0 ;
457
- for ( i, value) in running_runtimes. iter ( ) . enumerate ( ) {
458
- if value < & running_runtimes[ min_idx] {
459
- min_idx = i;
460
- }
461
- }
462
-
428
+ let min_idx = get_min_index ( & running_runtimes) ;
463
429
let test_name = get_test_name ( & test) ;
464
430
if let Some ( test_stats) = task_stats. test_map . get ( & test_name) {
465
431
running_runtimes[ min_idx] += test_stats. average_runtime ;
432
+ running_tests[ min_idx] . push ( test. clone ( ) ) ;
433
+ } else {
434
+ left_tests. push ( test. clone ( ) ) ;
466
435
}
467
- running_tests[ min_idx] . push ( test. clone ( ) ) ;
436
+ }
437
+
438
+ let min_idx = get_min_index ( & running_runtimes) ;
439
+ for ( i, test) in left_tests. iter ( ) . enumerate ( ) {
440
+ running_tests[ ( min_idx + i) % max_tasks] . push ( test. clone ( ) ) ;
468
441
}
469
442
470
443
let mut sub_suites = vec ! [ ] ;
@@ -731,6 +704,25 @@ fn sort_tests_by_runtime(
731
704
sorted_test_list
732
705
}
733
706
707
+ /// Get the index of sub suite with the least total runtime of tests.
708
+ ///
709
+ /// # Arguments
710
+ ///
711
+ /// * `running_runtimes` - Total runtimes of tests of sub suites.
712
+ ///
713
+ /// # Returns
714
+ ///
715
+ /// Index of sub suite with the least total runtime.
716
+ fn get_min_index ( running_runtimes : & [ f64 ] ) -> usize {
717
+ let mut min_idx = 0 ;
718
+ for ( i, value) in running_runtimes. iter ( ) . enumerate ( ) {
719
+ if value < & running_runtimes[ min_idx] {
720
+ min_idx = i;
721
+ }
722
+ }
723
+ min_idx
724
+ }
725
+
734
726
#[ async_trait]
735
727
impl GenResmokeTaskService for GenResmokeTaskServiceImpl {
736
728
/// Generate a task for running the given task in parallel.
@@ -1529,22 +1521,6 @@ mod tests {
1529
1521
assert_eq ! ( get_evg_fn_name( & commands[ 5 ] ) , Some ( "run test" ) ) ;
1530
1522
}
1531
1523
1532
- // percent_of_tests tests.
1533
- #[ rstest]
1534
- #[ case( 100 , 0.8 , 80 ) ]
1535
- #[ case( 100 , 1.0 , 100 ) ]
1536
- #[ case( 101 , 0.8 , 80 ) ]
1537
- #[ case( 99 , 0.8 , 79 ) ]
1538
- fn test_percent_of_tests (
1539
- #[ case] n_tests : usize ,
1540
- #[ case] percent : f32 ,
1541
- #[ case] expected_result : usize ,
1542
- ) {
1543
- let result = percent_of_tests ( n_tests, percent) ;
1544
-
1545
- assert_eq ! ( result, expected_result) ;
1546
- }
1547
-
1548
1524
// sort_tests_by_runtime tests.
1549
1525
#[ rstest]
1550
1526
#[ case( vec![ 100.0 , 50.0 , 30.0 , 25.0 , 20.0 , 15.0 ] , vec![ 0 , 1 , 2 , 3 , 4 , 5 ] ) ]
@@ -1586,4 +1562,15 @@ mod tests {
1586
1562
1587
1563
assert_eq ! ( result, expected_result) ;
1588
1564
}
1565
+
1566
+ // get_min_index tests.
1567
+ #[ rstest]
1568
+ #[ case( vec![ 100.0 , 50.0 , 30.0 , 25.0 , 20.0 , 15.0 ] , 5 ) ]
1569
+ #[ case( vec![ 15.0 , 20.0 , 25.0 , 30.0 , 50.0 , 100.0 ] , 0 ) ]
1570
+ #[ case( vec![ 25.0 , 50.0 , 15.0 , 30.0 , 100.0 , 20.0 ] , 2 ) ]
1571
+ fn test_get_min_index ( #[ case] running_runtimes : Vec < f64 > , #[ case] expected_min_idx : usize ) {
1572
+ let min_idx = get_min_index ( & running_runtimes) ;
1573
+
1574
+ assert_eq ! ( min_idx, expected_min_idx) ;
1575
+ }
1589
1576
}
0 commit comments