hydra-queue-runner: Cache the lookup of time spent per jobset

[?]
Sep 21, 2013, 7:54 PM
X3YLTWJAF7QLQGUVGDYALE75W4SJIOYZEFSGG726XRPGN576TWVQC

Dependencies

  • [2] GEADFVZ5 hydra-queue-runner: Improved scheduling
  • [3] NREF6YOA * Don't start more builds concurrently than allowed for each system
  • [4] YEXD7CBK Fix findBuildDependencyInQueue
  • [*] 7YBYT2LQ

Change contents

  • edit in src/script/hydra-queue-runner at line 110
    [2.3632]
    [2.3632]
    my $timeSpentPerJobset;
  • edit in src/script/hydra-queue-runner at line 122
    [2.3994]
    [2.3994]
    my $costPerBuild = 30;
  • replacement in src/script/hydra-queue-runner at line 130
    [2.4257][2.4257:4682]()
    my $duration = $jobset->builds->search(
    { },
    { where => \ ("(finished = 0 or (me.stoptime >= " . (time() - $windowSize) . "))")
    , join => 'buildsteps'
    , select => \ "sum(coalesce(buildsteps.stoptime, ${\time}) - buildsteps.starttime)"
    , as => "sum" })->single->get_column("sum") // 0;
    [2.4257]
    [2.4682]
    my $timeSpent = $timeSpentPerJobset->{$b->get_column('project')}->{$b->get_column('jobset')};
  • replacement in src/script/hydra-queue-runner at line 132
    [2.4683][2.4683:4972]()
    # Add a 30s penalty for each started build. This
    # is to account for jobsets that have running
    # builds but no build steps yet.
    $duration += $jobset->builds->search({ finished => 0, busy => 1 })->count * 30;
    [2.4683]
    [2.4972]
    if (!defined $timeSpent) {
    $timeSpent = $jobset->builds->search(
    { },
    { where => \ ("(finished = 0 or (me.stoptime >= " . (time() - $windowSize) . "))")
    , join => 'buildsteps'
    , select => \ "sum(coalesce(buildsteps.stoptime, ${\time}) - buildsteps.starttime)"
    , as => "sum" })->single->get_column("sum") // 0;
    # Add a 30s penalty for each started build. This
    # is to account for jobsets that have running
    # builds but no build steps yet.
    $timeSpent += $jobset->builds->search({ finished => 0, busy => 1 })->count * $costPerBuild;
    $timeSpentPerJobset->{$b->get_column('project')}->{$b->get_column('jobset')} = $timeSpent;
    }
  • edit in src/script/hydra-queue-runner at line 188
    [2.7220]
    [2.7220]
    $timeSpentPerJobset->{$jobset->get_column('project')}->{$jobset->name} += $costPerBuild;