Skip to content

Added functionality to cope with hybrid cgroups set ups - #7493

Open
ChrisPaulBennett wants to merge 11 commits into
cylc:8.7.xfrom
ChrisPaulBennett:hybrid-cgroups
Open

ChrisPaulBennett wants to merge 11 commits into
cylc:8.7.xfrom
ChrisPaulBennett:hybrid-cgroups

Conversation

@ChrisPaulBennett

@ChrisPaulBennett ChrisPaulBennett commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

The HPC cgroups in set up in a unified state. I'm assuming something has changed with the HPC set up, because this was working.
This unified set up has caused a refactor and added some complexity. CPU is controlled via v2 but memory is controlled by v1.
Due to both v1 and v2 being used together, there are instances of v2 files being present but having no data due to v1 being used. So the checking for cgroup versions has been made more robust.

Check List

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • Applied any dependency changes to both setup.cfg (and conda-environment.yml if present).
  • Tests are included (or explain why tests are not needed).
  • Changelog entry included if this is a change that can affect users
  • Cylc-Doc pull request opened if required at cylc/cylc-doc/pull/XXXX.
  • If this is a bug fix, PR should be raised against the relevant ?.?.x branch.

@ChrisPaulBennett ChrisPaulBennett self-assigned this Sep 30, 2026
@ChrisPaulBennett
ChrisPaulBennett marked this pull request as ready for review October 1, 2026 14:51
@MetRonnie MetRonnie added the bug Something is wrong :( label Oct 1, 2026
@MetRonnie MetRonnie added this to the 8.7.x milestone Oct 1, 2026

@jfrost-mo jfrost-mo 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.

The approach looks sensible, and it looks like the cgroup interaction should work. I've added several comments on the implementation specifics, and I still need to run it myself to test.

Comment thread tests/functional/README.md Resolved
Comment thread cylc/flow/scripts/profiler.py Resolved
Comment thread cylc/flow/scripts/profiler.py Resolved
Comment thread cylc/flow/scripts/profiler.py Resolved
Comment thread cylc/flow/scripts/profiler.py Resolved
Comment thread cylc/flow/scripts/profiler.py Resolved
Comment thread cylc/flow/scripts/profiler.py Resolved
Comment thread cylc/flow/scripts/profiler.py Resolved
Comment thread cylc/flow/scripts/profiler.py Resolved
Comment thread cylc/flow/scripts/profiler.py Resolved
Comment thread tests/functional/README.md Resolved
Comment thread cylc/flow/scripts/profiler.py Resolved
Comment thread cylc/flow/scripts/profiler.py Resolved
Comment thread cylc/flow/scripts/profiler.py Resolved
Comment thread cylc/flow/scripts/profiler.py Resolved
Comment thread cylc/flow/scripts/profiler.py Outdated
return Process(
cgroup_memory_path=memory_dir / "memory.stat",
cgroup_cpu_path=(
cpu_dir / ("cpu.stat" if cpu_version == 2 else "cpuacct.usage")

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.

When using the same string literals more than once, please extract into variables to protect against typos and future changes only affecting one instance etc.

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.

Done

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.

Not done?

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.

Done

jfrost-mo

This comment was marked as resolved.

@MetRonnie
MetRonnie changed the base branch from master to 8.7.x October 13, 2026 12:36

@jfrost-mo jfrost-mo 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.

Actually, the tests are failing (looks like a dodgy import) so going to leave on request changes until fixed.

@jfrost-mo jfrost-mo 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.

Looking good, and tests are now passing.

Comment thread cylc/flow/scripts/profiler.py Resolved

@MetRonnie MetRonnie 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.

Got some suggested tidying at ChrisPaulBennett#6

Co-authored-by: James Frost <james.frost@metoffice.gov.uk>

@jfrost-mo jfrost-mo 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.

Looking good.

@jfrost-mo
jfrost-mo requested a review from MetRonnie October 22, 2026 15:42
Comment thread tests/unit/scripts/test_profiler.py Resolved


def test_get_cgroup_names_test_env_var(monkeypatch):
"""It should allow the functional tests to inject a cgroup name."""

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.

Eh? Testing functionality only intended for the tests?

Can profiler_test_env_var be removed?

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.

If you can find another way to do it (I believe this was olivers suggestion, because I was stuck).

As described in comments this is a fugly hack, testing it makes less fugly, no?
Like make up on a bulldog?

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.

So the context I was missing is that profiler_test_env_var is used in 04-profiler.t.

We do not need to test this in the unit tests, if it's broken then 04-profiler.t will fail.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something is wrong :(

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants