Fix segfault sorting runnable steps

[?]
Mar 2, 2016, 12:59 PM
PDJCVDVY6R4ZCBELQR3KXPJ3LE7TVXG6N74USR7HWBOIE2P6HDAAC

Dependencies

  • [2] UPNGFCXG For completeness, re-implement meta.schedulingPriority
  • [3] TTBLPQAJ Keep track of wait time per system type
  • [4] EYR3EW6J Keep stats for the Hydra auto scaler
  • [5] 46ADBTMQ Start steps in order of ascending build ID
  • [6] 5N7LVAJN Keep track of requiredSystemFeatures in the machine stats
  • [7] WE5Q2NVI Allow build to be bumped to the front of the queue via the web interface
  • [8] 4I2HF4L3 Unindent
  • [9] IK2UBDAU Revive jobset scheduling
  • [10] MHVIT4JY Split hydra-queue-runner.cc more
  • [*] HJOEIMLR Refactor

Change contents

  • replacement in src/hydra-queue-runner/dispatcher.cc at line 147
    [2.1080][4.245:292](),[4.245][4.245:292]()
    std::vector<Step::ptr> runnableSorted;
    [2.1080]
    [3.66]
    struct StepInfo
    {
    Step::ptr step;
    /* The lowest share used of any jobset depending on this
    step. */
    double lowestShareUsed = 1e9;
    /* Info copied from step->state to ensure that the
    comparator is a partial ordering (see MachineInfo). */
    int highestGlobalPriority;
    int highestLocalPriority;
    BuildID lowestBuildID;
    StepInfo(Step::ptr step, Step::State & step_) : step(step)
    {
    for (auto & jobset : step_.jobsets)
    lowestShareUsed = std::min(lowestShareUsed, jobset->shareUsed());
    highestGlobalPriority = step_.highestGlobalPriority;
    highestLocalPriority = step_.highestLocalPriority;
    lowestBuildID = step_.lowestBuildID;
    }
    };
    std::vector<StepInfo> runnableSorted;
  • edit in src/hydra-queue-runner/dispatcher.cc at line 178
    [3.199]
    [3.199]
  • edit in src/hydra-queue-runner/dispatcher.cc at line 180
    [3.273]
    [4.292]
  • replacement in src/hydra-queue-runner/dispatcher.cc at line 200
    [4.3859][4.3859:3929](),[4.3929][3.364:476](),[3.476][4.3929:4105](),[4.3929][4.3929:4105](),[4.18166][4.18166:18222]()
    {
    auto step_(step->state.lock());
    r.waitTime += std::chrono::duration_cast<std::chrono::seconds>(now - step_->runnableSince);
    if (step_->tries > 0 && step_->after > now) {
    if (step_->after < sleepUntil)
    sleepUntil = step_->after;
    continue;
    }
    [4.3859]
    [4.423]
    auto step_(step->state.lock());
    r.waitTime += std::chrono::duration_cast<std::chrono::seconds>(now - step_->runnableSince);
    if (step_->tries > 0 && step_->after > now) {
    if (step_->after < sleepUntil)
    sleepUntil = step_->after;
    continue;
  • replacement in src/hydra-queue-runner/dispatcher.cc at line 208
    [4.442][4.442:490]()
    runnableSorted.push_back(step);
    [4.442]
    [4.490]
    runnableSorted.emplace_back(step, *step_);
  • edit in src/hydra-queue-runner/dispatcher.cc at line 212
    [4.515][4.906:1193]()
    for (auto & step : runnableSorted) {
    auto step_(step->state.lock());
    step_->lowestShareUsed = 1e9;
    for (auto & jobset : step_->jobsets)
    step_->lowestShareUsed = std::min(step_->lowestShareUsed, jobset->shareUsed());
    }
  • replacement in src/hydra-queue-runner/dispatcher.cc at line 213
    [4.574][4.574:631]()
    [](const Step::ptr & a, const Step::ptr & b)
    [4.574]
    [4.631]
    [](const StepInfo & a, const StepInfo & b)
  • edit in src/hydra-queue-runner/dispatcher.cc at line 215
    [4.645][4.645:749]()
    auto a_(a->state.lock());
    auto b_(b->state.lock()); // FIXME: deadlock?
  • replacement in src/hydra-queue-runner/dispatcher.cc at line 216
    [4.23][4.23:156](),[4.156][4.1194:1303](),[4.1303][2.1081:1210](),[2.1210][4.156:215](),[4.1303][4.156:215](),[4.156][4.156:215]()
    a_->highestGlobalPriority != b_->highestGlobalPriority ? a_->highestGlobalPriority > b_->highestGlobalPriority :
    a_->lowestShareUsed != b_->lowestShareUsed ? a_->lowestShareUsed < b_->lowestShareUsed :
    a_->highestLocalPriority != b_->highestLocalPriority ? a_->highestLocalPriority > b_->highestLocalPriority :
    a_->lowestBuildID < b_->lowestBuildID;
    [4.23]
    [4.811]
    a.highestGlobalPriority != b.highestGlobalPriority ? a.highestGlobalPriority > b.highestGlobalPriority :
    a.lowestShareUsed != b.lowestShareUsed ? a.lowestShareUsed < b.lowestShareUsed :
    a.highestLocalPriority != b.highestLocalPriority ? a.highestLocalPriority > b.highestLocalPriority :
    a.lowestBuildID < b.lowestBuildID;
  • replacement in src/hydra-queue-runner/dispatcher.cc at line 230
    [4.1178][4.1178:1227]()
    for (auto & step : runnableSorted) {
    [4.1178]
    [4.1227]
    for (auto & stepInfo : runnableSorted) {
    auto & step(stepInfo.step);
  • edit in src/hydra-queue-runner/state.hh at line 173
    [4.2151][4.4447:4565]()
    /* The lowest share used of any jobset depending on this
    step. */
    double lowestShareUsed;