Skip to content

libjob: add infrastructure for non-integer counts #6832

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

Merged
merged 6 commits into from
Jul 12, 2025

Conversation

sam-maloney
Copy link
Contributor

Problem: non-integer counts from RFC 14 are largely unsupported in flux-core.

This PR adds some initial infrastructure as a first step towards enabling non-integer counts; N.B. at present the new code is not actually used to do anything, this PR only includes the new struct definitions along with creation, encoding/decoding, and iteration functions (as well as initial unit testing).

The count wrapper structs are intended to present a similar interface (albeit a limited subset thereof) as libidset, particularly since flux-framework/rfc#442 proposes allowing counts to be given as idsets (which this PR implements). The iteration functions therefore intend to allow code to be agnostic to which type of count was actually given (integer, idset, or range). Any feedback on the design, etc. would be much appreciated!

The string representation for decoding/encoding of ranges is documented in the proposed RFC 45 at flux-framework/rfc#453

In conjunction with #6705 this will then allow non-integer ranges to be enabled in more parts of the code, such as job-listing, sched-simple, etc.

grondo
grondo previously approved these changes Jun 18, 2025
Copy link
Contributor

@grondo grondo left a comment

Choose a reason for hiding this comment

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

@sam-maloney, thanks, this is really well done! So far I had only a couple trivial comments inline. Thanks also for the extensive testing.

I do wonder if counts.[ch] belong in libutil, but for now libjob actually does seem a bit more appropriate and it could always be moved.

@mergify mergify bot dismissed grondo’s stale review June 30, 2025 13:31

Approving reviews have been dismissed because this pull request
was updated.

@sam-maloney
Copy link
Contributor Author

I do wonder if counts.[ch] belong in libutil, but for now libjob actually does seem a bit more appropriate and it could always be moved.

I definitely wasn't sure at all where best to put this, but since it grew from the parsing of jobspec in the shell init, which uses jj, I stuck the new code in libjob as well...

@sam-maloney sam-maloney requested a review from grondo June 30, 2025 14:03
Copy link
Contributor

@grondo grondo left a comment

Choose a reason for hiding this comment

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

LGTM! I'll set MWP.

Problem: to expand implementation of RFC 14, several components in core
will need to handle non-integer counts, but there is currently no support.

Add a new `count` wrapper struct to libjob that will contain one of an
integer, RFC 14 range, or RFC 22 idset, with an interface modelled as a
subset of the libidset interface. This commit implements the initial
decoding and encoding infrastructure.
Problem: new count struct decoding/encoding is untested.

Add unit test for count codec.
Problem: jobspec will specify count as JSON while currently only string
decoding is implemented.

Add function to parse JSON into a count and modify string decoder to
check for and dispatch strings which appear to contain JSON.
Problem: new count creation from JSON is untested.

Add initial JSON inputs to test cases for count codec.
Problem: cannot iterate through valid values for a count struct.

Add count_first() and count_next() functions to iterate through valid
values in a count struct, modelled after the interface of libidset.
Problem: new count struct iteration functions are untested.

Add unit test for count iteration functions.
@mergify mergify bot merged commit dacfccd into flux-framework:master Jul 12, 2025
35 checks passed
Copy link

codecov bot commented Jul 12, 2025

Codecov Report

Attention: Patch coverage is 98.54369% with 3 lines in your changes missing coverage. Please review.

Project coverage is 83.88%. Comparing base (3323cf0) to head (807f789).
Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
src/common/libjob/count.c 98.54% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6832      +/-   ##
==========================================
+ Coverage   83.83%   83.88%   +0.04%     
==========================================
  Files         539      540       +1     
  Lines       90283    90489     +206     
==========================================
+ Hits        75693    75905     +212     
+ Misses      14590    14584       -6     
Files with missing lines Coverage Δ
src/common/libjob/count.c 98.54% <98.54%> (ø)

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants