|
18 | 18 | // along with BOINC. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
|
20 | 20 | // identify batches that are almost complete, and accelerate their completion |
| 21 | +// We first run 'batch_stats.php', which computes needed data: |
| 22 | +// LTT hosts, accelerable batches, median TT of batches |
21 | 23 |
|
22 | 24 | require_once('../inc/util.inc'); |
23 | 25 | require_once('../inc/boinc_db.inc'); |
|
26 | 28 |
|
27 | 29 | ini_set('display_errors', true); |
28 | 30 |
|
29 | | -// accelerate batches if at least this frac done |
30 | | -// can be set in project.inc |
| 31 | +// the following can be set in project.inc |
31 | 32 | // |
32 | | -if (!defined('BATCH_ACCEL_MIN_FRAC_DONE')){ |
33 | | - define('BATCH_ACCEL_MIN_FRAC_DONE', .85); |
| 33 | +// accelerate a batch if at least this frac of jobs are done (success or fail) |
| 34 | +// This value is a guess; it may not be optimal. |
| 35 | +// If too low, extra instances are created, reducing throughput. |
| 36 | +// If too high, batches take longer to finish. |
| 37 | +// |
| 38 | +if (!defined('BATCH_ACCEL_MIN_FRAC_DONE')) { |
| 39 | + define('BATCH_ACCEL_MIN_FRAC_DONE', 0.85); |
| 40 | +} |
| 41 | + |
| 42 | +// accelerate a batch if the number of 'not done' jobs |
| 43 | +// (i.e. unsent or in progress) is less than this. |
| 44 | +// This helps small batches get done quicker |
| 45 | +// |
| 46 | +if (!defined('BATCH_ACCEL_MAX_NOT_DONE')) { |
| 47 | + define('BATCH_ACCEL_MAX_NOT_DONE', 20); |
34 | 48 | } |
35 | 49 |
|
36 | 50 | $apps = []; |
37 | 51 |
|
38 | | -// batch is in-progress and at least 90% done; accelerate its remaining jobs |
| 52 | +// batch is in-progress and qualifies for acceleration (see above); |
| 53 | +// accelerate its remaining jobs by marking them as high-priority |
| 54 | +// and possibly creating a new instance |
39 | 55 | // |
40 | 56 | function do_batch($batch, $wus) { |
41 | 57 | global $apps; |
@@ -78,7 +94,7 @@ function do_batch($batch, $wus) { |
78 | 94 | break; |
79 | 95 | case RESULT_SERVER_STATE_IN_PROGRESS: |
80 | 96 | $age = $now - $r->sent_time; |
81 | | - if ($age<$batch->expire_time) { |
| 97 | + if ($age < $batch->expire_time) { |
82 | 98 | echo " have recent in-progress result $r->id\n"; |
83 | 99 | $make_another_result = false; |
84 | 100 | } |
@@ -145,12 +161,16 @@ function main() { |
145 | 161 | echo "batch $batch->id not in progress\n"; |
146 | 162 | continue; |
147 | 163 | } |
148 | | - if ($batch->fraction_done < BATCH_ACCEL_MIN_FRAC_DONE) { |
149 | | - echo "batch $batch->id only $batch->fraction_done done\n"; |
150 | | - continue; |
| 164 | + $n_done = $batch->njobs_success + $batch->nerror_jobs; |
| 165 | + $n_not_done = count($wus) - $n_done; |
| 166 | + if ($batch->fraction_done > BATCH_ACCEL_MIN_FRAC_DONE |
| 167 | + || $n_not_done < BATCH_ACCEL_MAX_NOT_DONE |
| 168 | + ) { |
| 169 | + echo "doing batch $batch->id\n"; |
| 170 | + do_batch($batch, $wus); |
| 171 | + } else { |
| 172 | + echo "not doing batch $batch->id: $batch->fraction_done done\n"; |
151 | 173 | } |
152 | | - echo "doing batch $batch->id\n"; |
153 | | - do_batch($batch, $wus); |
154 | 174 | } |
155 | 175 | echo sprintf("finished batch_accel: %s\n", time_str(time())); |
156 | 176 | } |
|
0 commit comments