Skip to content

Commit

Permalink
Move creation of debug directory to dispatcher constructor, and empty…
Browse files Browse the repository at this point in the history
… the directory if it already exists.

This was previously checked and done every time the solver runs;
clearly, it's a setup measure that should happen at the start of day.

Affected modules: scheduling/flow

Change-Id: I1620dda787a3cd976b7fe0e6fe856eb691587c45
  • Loading branch information
ms705 committed Jun 26, 2015
1 parent f8c97e5 commit cfdc28b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
31 changes: 22 additions & 9 deletions src/scheduling/flow/solver_dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,28 @@ DEFINE_string(cs2_binary, "ext/cs2-4.6/cs2.exe", "Path to the cs2 binary.");

namespace firmament {
namespace scheduler {
using boost::lexical_cast;
using boost::algorithm::is_any_of;
using boost::token_compress_on;

using boost::lexical_cast;
using boost::algorithm::is_any_of;
using boost::token_compress_on;

SolverDispatcher::SolverDispatcher(shared_ptr<FlowGraph> flow_graph,
bool solver_ran_once)
: flow_graph_(flow_graph),
solver_ran_once_(solver_ran_once),
debug_seq_num_(0) {
// Set up debug directory if it doesn't exist
struct stat st;
if (!FLAGS_debug_output_dir.empty() &&
stat(FLAGS_debug_output_dir.c_str(), &st) == -1) {
mkdir(FLAGS_debug_output_dir.c_str(), 0700);
} else if (!FLAGS_debug_output_dir.empty()) {
// Delete any existing debug output in the directory
string cmd;
spf(&cmd, "rm %s/*", FLAGS_debug_output_dir.c_str());
system(cmd.c_str());
}
}

void *ExportToSolver(void *x) {
SolverDispatcher *qd = reinterpret_cast<SolverDispatcher*>(x);
Expand Down Expand Up @@ -124,12 +143,6 @@ multimap<uint64_t, uint64_t>* SolverDispatcher::Run(
*algorithm_time = nan("");
}

// Set up debug directory if it doesn't exist
struct stat st;
if (!FLAGS_debug_output_dir.empty() &&
stat(FLAGS_debug_output_dir.c_str(), &st) == -1) {
mkdir(FLAGS_debug_output_dir.c_str(), 0700);
}
// Adjusts the costs on the arcs from tasks to unsched aggs.
if (solver_ran_once_) {
flow_graph_->AdjustUnscheduledAggArcCosts();
Expand Down
6 changes: 1 addition & 5 deletions src/scheduling/flow/solver_dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ namespace scheduler {

class SolverDispatcher {
public:
SolverDispatcher(shared_ptr<FlowGraph> flow_graph, bool solver_ran_once)
: flow_graph_(flow_graph),
solver_ran_once_(solver_ran_once),
debug_seq_num_(0) {
}
SolverDispatcher(shared_ptr<FlowGraph> flow_graph, bool solver_ran_once);

void NodeBindingToSchedulingDelta(
const TaskDescriptor& task, const ResourceDescriptor& res,
Expand Down

0 comments on commit cfdc28b

Please sign in to comment.