Skip to content

For batched builds, use the whole node#5003

Merged
jgfouca merged 10 commits into
masterfrom
jgfouca/batched_build_use_whole_node
Jun 25, 2026
Merged

For batched builds, use the whole node#5003
jgfouca merged 10 commits into
masterfrom
jgfouca/batched_build_use_whole_node

Conversation

@jgfouca

@jgfouca jgfouca commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

GMAKE_J is generally used as a way to throttle builds so as to not overwhelm a login node. There is no such concern for a batched build, so just use the entire node.

Also, minor cleanup of batched build resource calculation in test_scheduler.

Also, add a check that the ninja exe is usable if the user asked for it.

Also, add support for communicating to sharedlib buildlib that ninja was requested.

Checklist

  • My code follows the style guidelines of this project (black formatting)
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that exercise my feature/fix and existing tests continue to pass
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding additions and changes to the documentation

GMAKE_J is generally used as a way to throttle builds so as
to not overwhelm a login node. There is no such concern for a
batched build, so just use the entire node.

Also, minor cleanup of batched build resource calculation in
test_scheduler.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts TestScheduler’s build resource heuristics so batched builds can use the full compute node (rather than being throttled by login-node-oriented GMAKE_J defaults), and slightly simplifies batched-build resource accounting.

Changes:

  • Treat batched builds as low “local” cost by setting _model_build_cost = 1 when BATCHED_BUILD is enabled.
  • In _xml_phase, set GMAKE_J to MAX_TASKS_PER_NODE for batched builds (while still capping GMAKE_J to proc_pool for small-core systems in the non-batched path).
  • Simplify _get_procs_needed for MODEL_BUILD_PHASE to always return _model_build_cost.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CIME/test_scheduler.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

Comment thread CIME/build.py Outdated
Comment thread CIME/tests/test_unit_test_scheduler.py Outdated
Comment on lines +345 to +349


from unittest import mock

from CIME import test_scheduler
Comment thread CIME/tests/test_unit_test_scheduler.py Outdated
Comment on lines +261 to +265
def test_no_batch_build_init_param_sets_attribute(self):
"""TestScheduler.__init__ sets _batched_build=False when no_batch_build=True."""
# We test the init logic in isolation by checking the attribute assignment
# path (lines 250-251 of test_scheduler.py) with a minimal mock.
with mock.patch.object(
Comment thread CIME/build.py
Comment on lines +511 to +519
# Make sure ninja exe works!
nstat, _, nerr = run_cmd(f"{ninja_path}/ninja --version")
if nstat != 0:
logger.warning(
f"Ninja exe does not appear to be usable: {nerr}\nFalling back to gmake"
)
else:
cmake_args += " -GNinja "
cmake_env += "PATH={}:$PATH ".format(ninja_path)
@jgfouca

jgfouca commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Sorry for the churn. This is ready for final review now.

Comment thread CIME/build.py Outdated
Comment on lines +837 to +838
check_ninja(case)
ninja = False

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct? It looks like check_ninja returns a logical, so I would expect something like ninja = check_ninja(case).

Either way, a comment would be helpful here. The current code is definitely unintuitive, even if it's correct: why do you set ninja = False if it's originally True? Even with my suggested change, a comment would help clarify what's going on... something like (if I'm understanding correctly): "User has requested a ninja-based build, but we need to check that this is possible; if not, we'll fall back to a non-ninja build"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Not sure what I was thinking here.

Comment thread CIME/build.py Outdated
else:
# We cannot know if the various buildlib scripts support ninja.
# Just set an env var to let them know ninja was requested.
os.environ["CIME_SHAREDLIB_NINJA"] = "TRUE"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely unintuitive, even if it's correct. It looks like this says: if ninja is false (so we're in the else block) then we're setting CIME_SHAREDLIB_NINJA to TRUE? That feels backwards.

My expectation is that this whole block would look like:

if ninja:
    # Explanatory comment here...
    ninja = check_ninja(case)

# If ninja is still true after the check....
if ninja:
    # We cannot know if the various buildlib scripts support ninja.
    # Just set an env var to let them know ninja was requested.
    os.environ["CIME_SHAREDLIB_NINJA"] = "TRUE"

If I'm wrong and the current logic is correct, it warrants some comments explaining what right now feels like unintuitive behavior.

@jgfouca jgfouca requested a review from billsacks June 25, 2026 17:00

@billsacks billsacks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now - I like the way you have set up the logic.

@jgfouca jgfouca merged commit 4f8637f into master Jun 25, 2026
9 checks passed
@jgfouca jgfouca deleted the jgfouca/batched_build_use_whole_node branch June 25, 2026 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants