Commit bb6d6ca9 authored by Leo Gordon's avatar Leo Gordon
Browse files

changed the meaning of 'num_required_workers' to "total estimated number of...

changed the meaning of 'num_required_workers' to "total estimated number of workers needed for this analysis" ( 'num_running_workers' is now included in it )
parent 2a72b4ce
......@@ -134,6 +134,8 @@ sub num_running_workers {
return $self->{'_num_running_workers'};
}
# NB: the meaning of this field changes from "how many workers we need to add" to "how many workers we actually need"
sub num_required_workers {
my $self = shift;
$self->{'_num_required_workers'} = shift if(@_);
......@@ -293,7 +295,7 @@ sub print_stats {
my $analysis = $self->get_analysis;
printf("%-27s(%2d) %11s jobs(Sem:%d, Rdy:%d, InProg:%d, Done+Pass:%d, Fail:%d)=%d Ave_msec:%d, ",
printf("%-27s(%2d) %11s jobs(Sem:%d, Rdy:%d, InProg:%d, Done+Pass:%d, Fail:%d)=%d Ave_msec:%d, workers(Running:%d, Reqired:%d) ",
$analysis->logic_name,
$self->analysis_id,
$self->status,
......@@ -306,9 +308,11 @@ sub print_stats {
$self->total_job_count,
$self->avg_msec_per_job,
$self->num_running_workers,
$self->num_required_workers,
);
print 'req.workers:'.$self->num_required_workers
.' h.cap:' .( defined($self->hive_capacity) ? $self->hive_capacity : '-' )
print ' h.cap:' .( defined($self->hive_capacity) ? $self->hive_capacity : '-' )
.' a.cap:' .( defined($analysis->analysis_capacity) ? $analysis->analysis_capacity : '-')
." (sync'd " .$self->seconds_since_last_update." sec ago)\n",
}
......
......@@ -90,7 +90,7 @@ sub fetch_all_by_suitability_rc_id_meadow_type {
# the ones that clearly have work to do:
#
my $primary_results = $self->_generic_fetch(
"ast.num_required_workers>0 AND ast.status in ('READY', 'WORKING')" ,
"ast.num_running_workers<ast.num_required_workers AND ast.status in ('READY', 'WORKING')" ,
$join ,
'ORDER BY a.priority DESC, ' . ( ($self->dbc->driver eq 'sqlite') ? 'RANDOM()' : 'RAND()' ),
);
......
......@@ -245,8 +245,8 @@ sub specialize_new_worker {
if($stats->status eq 'BLOCKED') {
die "Analysis is BLOCKED, can't specialize a worker";
}
if($stats->num_required_workers <= 0) {
die "Analysis requires 0 workers at the moment";
if($stats->num_running_workers >= $stats->num_required_workers) {
die "Analysis doesn't require extra workers at the moment";
}
if($stats->status eq 'DONE') {
die "Analysis is DONE, and doesn't require workers";
......@@ -580,12 +580,9 @@ sub synchronize_AnalysisStats {
if($self->db->hive_use_triggers()) {
my $job_count = $analysisStats->ready_job_count();
my $job_count = $analysisStats->ready_job_count();
my $required_workers = $scheduling_allowed
&& ( POSIX::ceil( $job_count / $analysisStats->get_or_estimate_batch_size() )
- $analysisStats->num_running_workers() );
$required_workers = 0 if($required_workers < 0);
my $required_workers = $scheduling_allowed && POSIX::ceil( $job_count / $analysisStats->get_or_estimate_batch_size() );
$analysisStats->num_required_workers( $required_workers );
......@@ -613,10 +610,7 @@ sub synchronize_AnalysisStats {
if($status eq 'READY') {
$analysisStats->ready_job_count($job_count);
my $required_workers = $scheduling_allowed
&& ( POSIX::ceil( $job_count / $analysisStats->get_or_estimate_batch_size() )
- $analysisStats->num_running_workers() );
$required_workers = 0 if($required_workers < 0);
my $required_workers = $scheduling_allowed && POSIX::ceil( $job_count / $analysisStats->get_or_estimate_batch_size() );
$analysisStats->num_required_workers( $required_workers );
......@@ -843,7 +837,7 @@ sub suggest_analysis_to_specialize_by_rc_id_meadow_type {
#synchronize and double check that it can be run:
$self->safe_synchronize_AnalysisStats($stats);
return $stats if( ($stats->status ne 'BLOCKED') and ($stats->status ne 'SYNCHING') and ($stats->num_required_workers > 0) );
return $stats if( ($stats->status ne 'BLOCKED') and ($stats->status ne 'SYNCHING') and ($stats->num_running_workers < $stats->num_required_workers) );
}
return undef;
......
......@@ -121,8 +121,10 @@ sub schedule_workers {
next if($analysis_stats->status eq 'BLOCKED');
# getting the initial worker requirement for this analysis (may be stale if not sync'ed recently)
my $workers_this_analysis = $analysis_stats->num_required_workers
or next;
my $extra_workers_this_analysis = $analysis_stats->num_required_workers - $analysis_stats->num_running_workers;
# if this analysis doesn't require any extra workers - just skip it:
next if ($extra_workers_this_analysis <= 0);
# setting up all negotiating limiters:
$queen_capacity->multiplier( $analysis_stats->hive_capacity );
......@@ -135,22 +137,22 @@ sub schedule_workers {
# negotiations:
foreach my $limiter (@limiters) {
$workers_this_analysis = $limiter->preliminary_offer( $workers_this_analysis );
$extra_workers_this_analysis = $limiter->preliminary_offer( $extra_workers_this_analysis );
}
# do not continue with this analysis if limiters haven't agreed on a positive number:
next unless($workers_this_analysis);
next unless($extra_workers_this_analysis);
# let all parties know the final decision of negotiations:
foreach my $limiter (@limiters) {
$limiter->final_decision( $workers_this_analysis );
$limiter->final_decision( $extra_workers_this_analysis );
}
my $this_rc_name = $analysis_id2rc_name->{ $analysis_stats->analysis_id };
$workers_to_submit_by_meadow_type_rc_name{ $this_meadow_type }{ $this_rc_name } += $workers_this_analysis;
$total_workers_to_submit += $workers_this_analysis;
$workers_to_submit_by_meadow_type_rc_name{ $this_meadow_type }{ $this_rc_name } += $extra_workers_this_analysis;
$total_workers_to_submit += $extra_workers_this_analysis;
$analysis_stats->print_stats();
printf("Before checking the Valley for pending jobs, Scheduler allocated $workers_this_analysis x $this_meadow_type:$this_rc_name workers for '%s' [%.4f hive_load remaining]\n",
printf("Before checking the Valley for pending jobs, Scheduler allocated $extra_workers_this_analysis x $this_meadow_type:$this_rc_name extra workers for '%s' [%.4f hive_load remaining]\n",
$analysis->logic_name,
$queen_capacity->available_capacity,
);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment