myxce/src/lib
Rongsong Shen fa34b038f7
refactor(scheduler): move job-total limit computation to the limit plugin (bug-1790)
bug-1790's fix worked but put limit-plugin-specific logic in the wrong
place: seqjob_prepare_allocation()/parjob_prepare_allocation() (the
allocator plugins) unconditionally pre-computed a job-wide total for
every per-host resource in the job's rusages, "just in case" some
global limit needed one. That's the allocator plugins' concern leaking
into limit evaluation -- duplicated across both allocators (a third
would need it too), and wasteful (computed for resources no limit
actually references).

Moved ownership to sched_fill_limit_requests() (resource.c), called
once centrally from plugin_prepare_allocation() regardless of which
allocator ran:

- Removed calc_wanted_host_resval_job_totals() and its calls from both
  allocator plugins entirely.
- Added calc_wanted_job_total_resval() (resreq.c): an on-demand,
  single-resource lookup by name (no resmgr/key_find needed -- the
  caller already has the resolved xce_resource_t), computing the same
  job-wide-total formula only for the one (scope, underlying-resource)
  combination that needs it -- a GLOBAL limit on a per-host resource.
  The other three combinations are unchanged, still reading straight
  out of alloc_req.
- sched_fill_limit_requests() gains rusages/nhosts/nslots parameters
  back (a genuine need this time, not a re-added unused one).
  plugin.c's two call sites pass obj->u.primary->resreq->rusages
  (NULL for COMPOUND/ALTER, matching this codebase's existing scope
  convention for those tags) and ctx->nhosts/ctx->nslots.

All 23 testsuite link-satisfying stubs mechanically updated. Removed
the two allocator-level regression tests from the first pass (the
behavior they proved no longer exists by design); rewrote
test_fill_limit_requests_global_limit_on_host_resource_reads_host to
exercise the new on-demand path directly, nslots=3 to prove the job's
WHOLE total is used.

Full xce-build.sh all asan --incremental: 94/94 Ok, zero regressions.
Live re-verified against the same ug1_global_mem deploy/scenario:
byte-identical scheduler trace to the pre-refactor result, confirming
behavior-preserving.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GLfB5uWRdmx2WiZSFC7Fm7
2026-09-08 10:44:07 +00:00
..
raft fix(ha): bug-1421 close term-desync AE-reject blindspot in HA election 2026-07-09 11:56:46 +00:00
testsuite fix(lib): free host_account.host and job_account test fixtures (bug-1723, bug-1621) 2026-09-08 09:16:20 +00:00
bitset.c - introduce bitset 2026-02-13 11:01:33 +08:00
CLAUDE.md update documents 2026-08-10 17:51:51 +08:00
client.c fix(scheduler): close post-failover rejoin detection gap (bug-1760) 2026-09-04 04:37:11 +00:00
client_failover.c fix(libxce-failover): correct endpoint reconnect on rotate — re-bind iomgr + re-arm handlers (fixes endpoint_connect SEGV during live failover) 2026-06-17 06:53:46 +00:00
client_internal.h fix(libxce): bug-1425 -- populate jobsubmit's *jobid on idempotent-replay success 2026-08-16 10:47:09 +00:00
cluster.c feat(component-failover-adoption): add candidate-list-to-client-config helper 2026-08-11 04:57:31 +00:00
configobj.c save works 2026-03-04 18:18:53 +08:00
dataq.c reformat code and job array 2025-11-07 16:14:27 +08:00
delay.c fix(lib): normalize delaymgr to one CLOCK_MONOTONIC ms timescale, fixing seconds-task starvation 2026-07-02 03:40:08 +00:00
group.c fix(scheduler): fix limit-plugin usergroup/scope/error-code cascade (gitea#46) 2026-09-07 12:44:16 +00:00
helper.c fix(bug-1737): scheduler can never learn a job finished successfully 2026-08-31 04:20:27 +00:00
hook.c fix bug-1060 bug-1067 2026-06-24 17:05:43 +08:00
htab.c docs: mark Phase 6 complete in phase6-scheduler-integration-plan 2026-04-30 07:17:32 +00:00
idgen.c jobid generate 2025-11-07 18:17:34 +08:00
jobj.c fix(lib): thread from_host through the wire format and the job-submit interning object (bug-1676, gitea #44) 2026-08-24 15:14:42 +00:00
kv.c feat: implement kvmgr_capture_keys for lock-free checkpoint serialization (P0-14a) 2026-05-07 11:07:41 +00:00
kvmgr.c fix(job-array-single-wal-record): close bug-1443's bulk-insert partial-visibility gap 2026-07-16 15:08:02 +00:00
meson.build feat(resreq-maxtasks-wiring): add task-count derivation helper 2026-09-06 03:26:32 +00:00
misc.c fix(lib): free host_account.host and job_account test fixtures (bug-1723, bug-1621) 2026-09-08 09:16:20 +00:00
mylock.c Init commit of jobs output/error message peek project. 2026-05-09 16:57:54 +08:00
netio.c fix(netio): bug-1447 same-batch endpoint use-after-free in io_worker dispatch 2026-07-18 13:28:04 +00:00
ordq.c pass pend reason back to controller 2025-12-23 15:29:26 +08:00
preason.c support limit 2026-01-12 15:27:54 +08:00
qobj.c save works 2026-03-05 16:03:37 +08:00
request.c feat(worker-rejoin-resync): add reconciliation wire codec helpers (task 1.4) 2026-09-01 09:34:25 +00:00
resobj.c refactor(controller,xceadmin): drop generic Resource.unit, hardcode bytes for maxmem 2026-08-13 08:27:16 +00:00
resreq.c refactor(scheduler): move job-total limit computation to the limit plugin (bug-1790) 2026-09-08 10:44:07 +00:00
rusage.peg fix typo of perflag && reformat .peg 2026-02-09 10:58:30 +08:00
section.peg docs: mark Phase 6 complete in phase6-scheduler-integration-plan 2026-04-30 07:17:32 +00:00
threshold.c reformat code and job array 2025-11-07 16:14:27 +08:00
utils.c feat(dirty-content-fingerprint): add --version-only composition with dirty_fingerprint 2026-08-21 05:19:12 +00:00
vtaskmgr.c fix(bug-1733): fix heap-use-after-free race in vtask_enq() 2026-08-29 11:28:48 +00:00
window.c reformat code and job array 2025-11-07 16:14:27 +08:00
wobj.c add kiro skills 2026-05-21 03:41:57 +00:00
wrap.c reformat code and job array 2025-11-07 16:14:27 +08:00
xce_resreq.peg docs: mark Phase 6 complete in phase6-scheduler-integration-plan 2026-04-30 07:17:32 +00:00
xce_select.c fix: sel_key_cmp_fn padding-byte mismatch in kvtab lookups 2026-05-12 09:53:59 +00:00
xce_select.peg docs: mark Phase 6 complete in phase6-scheduler-integration-plan 2026-04-30 07:17:32 +00:00
xcealloc.c feat(scheduler-snapshot-job-allocation): add dup_job_alloc deep-copy primitive 2026-08-27 12:07:27 +00:00
xceapi.c feat(config-upgrade-snapshot): live config-upgrade soak infra + fix bug-1468/bug-1469 (task 8.6) 2026-07-25 15:48:20 +00:00
xcectx.c fix(component-failover-adoption): Phase 6 -- close apiserver's idle-period rejoin gap (bug-1548/bug-1549) 2026-08-16 03:42:03 +00:00
xcelimit.c fix(scheduler): fix limit-plugin usergroup/scope/error-code cascade (gitea#46) 2026-09-07 12:44:16 +00:00
xcelist.c remove extralib 2026-09-04 11:24:43 +08:00
xlist.c support limit 2026-01-12 15:27:54 +08:00
xstring.c docs: mark Phase 6 complete in phase6-scheduler-integration-plan 2026-04-30 07:17:32 +00:00
xvec.c using xvec related api in scheduler 2026-01-16 18:21:37 +08:00
zarray.c fix(job-array-single-wal-record): close bug-1443's bulk-insert partial-visibility gap 2026-07-16 15:08:02 +00:00