Skip to content

Commit b3fbafe

Browse files
committed
traverser: move constraint checking to prune function
Problem: matching jobspecs with node constraints is currently implemented in such a way that the recursive dom_* call occurs before constraint checking. Move the node constraint check within the prune function to prevent unnecessary recursive dom_* calls, speeding up feasibility checks.
1 parent 6e6576d commit b3fbafe

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

resource/traversers/dfu_impl.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,14 @@ int dfu_impl_t::prune (const jobmeta_t &meta, bool exclusive,
209209
rc = -1;
210210
goto done;
211211
}
212+
// RFC 31 constraints only match against type == "node"
213+
// unspecified constraint matches everything
214+
if (meta.constraint != nullptr
215+
&& (*m_graph)[u].type == "node"
216+
&& !meta.constraint->match ((*m_graph)[u])) {
217+
rc = -1;
218+
goto done;
219+
}
212220
// if rack has been allocated exclusively, no reason to descend further.
213221
if ( (rc = by_avail (meta, s, u, resources)) == -1)
214222
goto done;
@@ -705,13 +713,6 @@ int dfu_impl_t::dom_dfv (const jobmeta_t &meta, vtx_t u,
705713
*excl = x_in;
706714
(*m_graph)[u].idata.colors[dom] = m_color.black ();
707715

708-
// RFC 31 constraints only match against type == "node"
709-
// unspecified constraint matches everything
710-
if (meta.constraint != nullptr
711-
&& (*m_graph)[u].type == "node"
712-
&& !meta.constraint->match ((*m_graph)[u]))
713-
goto done;
714-
715716
p = (*m_graph)[u].schedule.plans;
716717
if ( (avail = planner_avail_resources_during (p, at, duration)) == 0) {
717718
goto done;

0 commit comments

Comments
 (0)