Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support deferred job start time #1013

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions resource/modules/resource_match.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1643,6 +1643,9 @@ static int run (std::shared_ptr<resource_ctx_t> &ctx, int64_t jobid,
else if (std::string ("allocate_orelse_reserve") == cmd)
rc = tr.run (j, ctx->writers, match_op_t::MATCH_ALLOCATE_ORELSE_RESERVE,
jobid, at);
else if (std::string ("deferred_orelse_reserve") == cmd)
rc = tr.run (j, ctx->writers, match_op_t::DEFERRED_ORELSE_RESERVE,
jobid, at);
else if (std::string ("satisfiability") == cmd)
rc = tr.run (j, ctx->writers, match_op_t::MATCH_SATISFIABILITY,
jobid, at);
Expand Down
1 change: 1 addition & 0 deletions resource/policies/base/matcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ enum match_score_t { MATCH_UNMET = 0, MATCH_MET = 1 };
enum class match_op_t { MATCH_ALLOCATE,
MATCH_ALLOCATE_W_SATISFIABILITY,
MATCH_ALLOCATE_ORELSE_RESERVE,
DEFERRED_ORELSE_RESERVE,
MATCH_SATISFIABILITY };

/*! Base matcher data class.
Expand Down
3 changes: 3 additions & 0 deletions resource/traversers/dfu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ int dfu_traverser_t::schedule (Jobspec::Jobspec &jobspec,
m_total_postorder += detail::dfu_impl_t::get_postorder_count ();
break;
}
// Fall through for deferred since it is equivalent to
// MATCH_ALLOCATE_ORELSE_RESERVE with a different "at" time.
case match_op_t::DEFERRED_ORELSE_RESERVE:
case match_op_t::MATCH_ALLOCATE_ORELSE_RESERVE: {
/* Or else reserve */
errno = 0;
Expand Down
18 changes: 18 additions & 0 deletions resource/traversers/dfu_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,24 @@ struct jobmeta_t {
m_queue_set = true;
}
constraint = jobspec.attributes.system.constraint;
// If user specifies optional deferred_start and deferred_from keys
// use the elapsed time between now and deferred_from as the offset
// to compute the updated "at" time for the allocation.
auto deferred_start =
jobspec.attributes.system.optional.find ("deferred_start");
auto deferred_from =
jobspec.attributes.system.optional.find ("deferred_from");
if (deferred_start != jobspec.attributes.system.optional.end ()
&& deferred_from != jobspec.attributes.system.optional.end ()) {
int64_t now = std::chrono::duration_cast<std::chrono::seconds>
(std::chrono::system_clock::now ().time_since_epoch ()).count ();
int64_t elapsed = now - deferred_from->second.as<int64_t> ();
if (elapsed < 0)
at = 0;
else
at = deferred_start->second.as<int64_t> () - elapsed;
}

return 0;
}

Expand Down
12 changes: 9 additions & 3 deletions resource/utilities/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ struct command_t {

command_t commands[] = {
{ "match", "m", cmd_match, "Allocate or reserve matching resources (subcmd: "
"allocate | allocate_with_satisfiability | allocate_orelse_reserve) | "
"satisfiability: "
"resource-query> match allocate jobspec"},
"allocate | allocate_with_satisfiability | allocate_orelse_reserve | "
"deferred_orelse_reserve) | satisfiability: "
"resource-query> match allocate jobspec" },
{ "multi-match", "M", cmd_match_multi, "Allocate or reserve for "
"multiple jobspecs (subcmd: allocate | allocate_with_satisfiability | "
"allocate_orelse_reserve): "
Expand Down Expand Up @@ -200,6 +200,10 @@ static int run_match (std::shared_ptr<resource_context_t> &ctx, int64_t jobid,
rc2 = ctx->traverser->run (job, ctx->writers, match_op_t::
MATCH_ALLOCATE_ORELSE_RESERVE,
(int64_t)jobid, &at);
else if (cmd == "deferred_orelse_reserve")
rc2 = ctx->traverser->run (job, ctx->writers, match_op_t::
DEFERRED_ORELSE_RESERVE,
(int64_t)jobid, &at);
else if (cmd == "satisfiability")
rc2 = ctx->traverser->run (job, ctx->writers, match_op_t::
MATCH_SATISFIABILITY,
Expand Down Expand Up @@ -252,6 +256,7 @@ int cmd_match (std::shared_ptr<resource_context_t> &ctx,
}
std::string subcmd = args[1];
if (!(subcmd == "allocate" || subcmd == "allocate_orelse_reserve"
|| subcmd == "deferred_orelse_reserve"
|| subcmd == "allocate_with_satisfiability"
|| subcmd == "satisfiability")) {
std::cerr << "ERROR: unknown subcmd " << args[1] << std::endl;
Expand Down Expand Up @@ -289,6 +294,7 @@ int cmd_match_multi (std::shared_ptr<resource_context_t> &ctx,
}
std::string subcmd = args[1];
if (!(subcmd == "allocate" || subcmd == "allocate_orelse_reserve"
|| subcmd == "deferred_orelse_reserve"
|| subcmd == "allocate_with_satisfiability")) {
std::cerr << "ERROR: unknown subcmd " << args[1] << std::endl;
return 0;
Expand Down
6 changes: 6 additions & 0 deletions t/data/resource/commands/basics/cmds13.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# 4x cluster[1]->rack[1]->node[1]->slot[1]->socket[1]->core[1]
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/basics/test016.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/basics/test016.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/basics/test016.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/basics/test016.yaml
quit
11 changes: 11 additions & 0 deletions t/data/resource/commands/basics/cmds14.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 4x cluster[1]->rack[1]->node[1]->slot[1]->socket[1]->core[1]
match allocate @TEST_SRCDIR@/data/resource/jobspecs/basics/test001.yaml
match allocate @TEST_SRCDIR@/data/resource/jobspecs/basics/test001.yaml
match allocate @TEST_SRCDIR@/data/resource/jobspecs/basics/test001.yaml
match allocate @TEST_SRCDIR@/data/resource/jobspecs/basics/test001.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/basics/test016.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/basics/test016.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/basics/test016.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/basics/test016.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/basics/test016.yaml
quit
52 changes: 52 additions & 0 deletions t/data/resource/commands/cancel/cmds03.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test018.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test019.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test020.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test021.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test022.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test023.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test024.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test025.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test026.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test027.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test028.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test029.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test030.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test031.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test032.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test033.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test034.yaml
cancel 1
cancel 2
cancel 3
cancel 4
cancel 5
cancel 6
cancel 7
cancel 8
cancel 9
cancel 10
cancel 11
cancel 12
cancel 13
cancel 14
cancel 15
cancel 16
cancel 17
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test018.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test019.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test020.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test021.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test022.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test023.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test024.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test025.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test026.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test027.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test028.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test029.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test030.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test031.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test032.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test033.yaml
match deferred_orelse_reserve @TEST_SRCDIR@/data/resource/jobspecs/cancel/test034.yaml
quit
40 changes: 40 additions & 0 deletions t/data/resource/expected/basics/100.R.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---------------core35[1:x]
------------socket1[1:x]
---------node1[1:s]
------rack0[1:s]
---tiny0[1:s]
INFO: =============================
INFO: JOBID=1
INFO: RESOURCES=RESERVED
INFO: SCHEDULED AT=1800
INFO: =============================
---------------core17[1:x]
------------socket0[1:x]
---------node1[1:s]
------rack0[1:s]
---tiny0[1:s]
INFO: =============================
INFO: JOBID=2
INFO: RESOURCES=RESERVED
INFO: SCHEDULED AT=1800
INFO: =============================
---------------core35[1:x]
------------socket1[1:x]
---------node0[1:s]
------rack0[1:s]
---tiny0[1:s]
INFO: =============================
INFO: JOBID=3
INFO: RESOURCES=RESERVED
INFO: SCHEDULED AT=1800
INFO: =============================
---------------core17[1:x]
------------socket0[1:x]
---------node0[1:s]
------rack0[1:s]
---tiny0[1:s]
INFO: =============================
INFO: JOBID=4
INFO: RESOURCES=RESERVED
INFO: SCHEDULED AT=1800
INFO: =============================
90 changes: 90 additions & 0 deletions t/data/resource/expected/basics/101.R.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---------------core35[1:x]
------------socket1[1:x]
---------node1[1:s]
------rack0[1:s]
---tiny0[1:s]
INFO: =============================
INFO: JOBID=1
INFO: RESOURCES=ALLOCATED
INFO: SCHEDULED AT=Now
INFO: =============================
---------------core17[1:x]
------------socket0[1:x]
---------node1[1:s]
------rack0[1:s]
---tiny0[1:s]
INFO: =============================
INFO: JOBID=2
INFO: RESOURCES=ALLOCATED
INFO: SCHEDULED AT=Now
INFO: =============================
---------------core35[1:x]
------------socket1[1:x]
---------node0[1:s]
------rack0[1:s]
---tiny0[1:s]
INFO: =============================
INFO: JOBID=3
INFO: RESOURCES=ALLOCATED
INFO: SCHEDULED AT=Now
INFO: =============================
---------------core17[1:x]
------------socket0[1:x]
---------node0[1:s]
------rack0[1:s]
---tiny0[1:s]
INFO: =============================
INFO: JOBID=4
INFO: RESOURCES=ALLOCATED
INFO: SCHEDULED AT=Now
INFO: =============================
---------------core35[1:x]
------------socket1[1:x]
---------node1[1:s]
------rack0[1:s]
---tiny0[1:s]
INFO: =============================
INFO: JOBID=5
INFO: RESOURCES=RESERVED
INFO: SCHEDULED AT=3600
INFO: =============================
---------------core17[1:x]
------------socket0[1:x]
---------node1[1:s]
------rack0[1:s]
---tiny0[1:s]
INFO: =============================
INFO: JOBID=6
INFO: RESOURCES=RESERVED
INFO: SCHEDULED AT=3600
INFO: =============================
---------------core35[1:x]
------------socket1[1:x]
---------node0[1:s]
------rack0[1:s]
---tiny0[1:s]
INFO: =============================
INFO: JOBID=7
INFO: RESOURCES=RESERVED
INFO: SCHEDULED AT=3600
INFO: =============================
---------------core17[1:x]
------------socket0[1:x]
---------node0[1:s]
------rack0[1:s]
---tiny0[1:s]
INFO: =============================
INFO: JOBID=8
INFO: RESOURCES=RESERVED
INFO: SCHEDULED AT=3600
INFO: =============================
---------------core35[1:x]
------------socket1[1:x]
---------node1[1:s]
------rack0[1:s]
---tiny0[1:s]
INFO: =============================
INFO: JOBID=9
INFO: RESOURCES=RESERVED
INFO: SCHEDULED AT=7200
INFO: =============================
Loading
Loading