feat(scheduler-sim-decision-parity): relocate resource accounting to core-level (task 1.1)
Relocates sched_account_jobs()/sched_charge_account()/sched_uncharge_account()/ sched_update_account()/sched_update_res_accounts()/sched_commit_job_alloc() from xce_scheduler_t* to xce_sched_core_t*, mirroring the sched_resolve_job_picker() precedent, so the simulation driver can call the same accounting service the normal-mode driver already uses. Pure signature relocation -- every body reference was already sched->core.*, no logic change. Updates the 3 real call sites (driver.c's normal-mode round, scheduler.c's sched_begin_session and sched_commit_decision) and 7 existing tests' link-satisfying stub signatures. Adds test_resource_accounting.c proving Requirement 1.4: the relocated accounting produces identical resInUse/sharedInUse output whether called against a core embedded in xce_scheduler_t or xce_sched_sim_driver_t. 43/44 scheduler tests pass; the 1 failure is pre-existing bug-1560 (unrelated recording.c sandbox-permission ordering issue). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
0b2c856d8b
commit
3106c82ed0
15 changed files with 498 additions and 75 deletions
|
|
@ -246,6 +246,47 @@ extern int sched_queue_is_ready(xce_sched_queue_t*);
|
|||
*/
|
||||
extern int sched_resolve_job_picker(xce_sched_core_t*, xce_sched_plugin_t**);
|
||||
|
||||
/*
|
||||
* sched_account_jobs/sched_charge_account/sched_uncharge_account/
|
||||
* sched_commit_job_alloc - resource-in-use accounting (scheduler-sim-
|
||||
* decision-parity spec, task 1.1). Relocated from scheduler.c/resource.c's
|
||||
* xce_scheduler_t* signature to this xce_sched_core_t* signature, following
|
||||
* the exact same precedent sched_resolve_job_picker established above (task
|
||||
* 4.3): pure signature relocation, body unchanged -- every reference in
|
||||
* these functions' bodies already only touched sched->core.* before this
|
||||
* move. Moved so the simulation driver (which has no xce_scheduler_t* of
|
||||
* its own, only xce_sched_core_t) can call the same accounting service the
|
||||
* normal-mode driver already uses, restoring the resource-in-use accounting
|
||||
* parity `.kiro/steering/scheduler-driver-equivalence.md` documents.
|
||||
*
|
||||
* sched_account_jobs() - re-derives resInUse/sharedInUse from every
|
||||
* currently-running job's known resource allocation (job->accounts != NULL)
|
||||
* by re-charging each one via sched_charge_account(). Skips a RUN-state job
|
||||
* whose allocation is not yet known -- not an error; see
|
||||
* scheduler-sim-decision-parity design.md's Recorded-Decision Reconciliation
|
||||
* component for why that is the expected state before this call runs.
|
||||
* Callers (both drivers) must call this strictly after the session's resval
|
||||
* reset and strictly before the picker/allocator are unblocked -- see
|
||||
* xce_core_begin_session()/xce_core_signal_go()'s own doc comment below for
|
||||
* the full ordering contract this depends on. Was exported (no longer
|
||||
* `static`) as of scheduler-core spec task 5.2 for the identical reason;
|
||||
* still defined in scheduler.c, only its declaration/signature move here.
|
||||
*
|
||||
* sched_charge_account()/sched_uncharge_account() - add/remove one job's
|
||||
* xce_job_account_t (shared + per-host resource usage) to/from
|
||||
* core->sharedInUse and each worker's resInUse.
|
||||
*
|
||||
* sched_commit_job_alloc() - charges a job's already-resolved allocation
|
||||
* (job->accounts) via sched_charge_account(); a no-op (returns 0) if the
|
||||
* job's allocation is not yet known. Called by sched_commit_decision()
|
||||
* (scheduler.c) immediately after a fresh DISPATCH decision populates
|
||||
* job->allocs/job->accounts.
|
||||
*/
|
||||
extern int sched_account_jobs(xce_sched_core_t*);
|
||||
extern int sched_charge_account(xce_sched_core_t*, xce_job_account_t*);
|
||||
extern int sched_uncharge_account(xce_sched_core_t*, xce_job_account_t*);
|
||||
extern int sched_commit_job_alloc(xce_sched_core_t*, xce_sched_job_t*);
|
||||
|
||||
/*
|
||||
* xce_core_event_type_t / xce_core_event_t - the core's typed input-event
|
||||
* representation (scheduler-core spec, task 4.3, Req 5 AC 4). Exactly the 9
|
||||
|
|
|
|||
|
|
@ -252,17 +252,14 @@ extern int sched_update(xce_scheduler_t*);
|
|||
extern void sched_go(xce_scheduler_t*);
|
||||
extern void sched_begin_session(xce_scheduler_t*);
|
||||
extern void sched_end_session(xce_scheduler_t*);
|
||||
/* sched_account_jobs - per-running-job resource-in-use accounting
|
||||
* (re-charges every RUN-state job's resources via sched_charge_account()
|
||||
* after sched_begin_session()'s resval reset zeroes them). Exported as of
|
||||
* scheduler-core spec task 5.2 so the new normal-mode driver loop
|
||||
* (driver.c's xce_sched_driver_run_normal_mode_round()) can call it
|
||||
* directly at the exact
|
||||
* point xce_core_begin_session()'s caller must call it: after the resval
|
||||
* reset, strictly before xce_core_signal_go() unblocks the picker thread.
|
||||
* Was `static`; body unchanged, still also called from
|
||||
* sched_begin_session() below (unchanged legacy call site). */
|
||||
extern int sched_account_jobs(xce_scheduler_t*);
|
||||
/* sched_account_jobs/sched_charge_account/sched_uncharge_account/
|
||||
* sched_commit_job_alloc relocated to core.h (scheduler-sim-decision-parity
|
||||
* spec, task 1.1) -- same rationale as sched_resolve_job_picker above: they
|
||||
* now operate on xce_sched_core_t*, not xce_scheduler_t*, so the simulation
|
||||
* driver (mode-agnostic, no xce_scheduler_t* of its own) gains the same
|
||||
* accounting capability the normal-mode driver already had. Call sites in
|
||||
* this file (sched_begin_session() below, sched_commit_decision()) now pass
|
||||
* &sched->core. See core.h for the full contract; body unchanged. */
|
||||
/* sched_get_job/sched_add_job/sched_get_queue/sched_add_queue/
|
||||
* sched_get_worker/sched_add_worker/sched_get_user/sched_add_user/
|
||||
* sched_get_project/sched_add_project/sched_job_is_ready/
|
||||
|
|
@ -284,9 +281,6 @@ extern int sched_check_host_satisfy(xce_scheduler_t*, xce_sched_worker_t*,
|
|||
extern int sched_collect_workers(xce_scheduler_t*, xlist_t*,
|
||||
zarray_iter_skip_fn_t,
|
||||
sched_group_worker_fn_t);
|
||||
extern int sched_charge_account(xce_scheduler_t*, xce_job_account_t*);
|
||||
extern int sched_uncharge_account(xce_scheduler_t*, xce_job_account_t*);
|
||||
extern int sched_commit_job_alloc(xce_scheduler_t*, xce_sched_job_t*);
|
||||
extern uint64_t sched_get_id(xce_scheduler_t*);
|
||||
extern xce_alloc_t** sched_make_allocs(xce_scheduler_t*, char*, int, int*,
|
||||
float*, int*);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue