feat(libxce-alloc-preason-equality): recorded dispatch fixtures carry the session-start from (task 4.2)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-09-28 10:44:00 +00:00
parent 6110d12e5a
commit 69112c2d22
Signed by untrusted user: rshen
GPG key ID: 80533536B0EB651C
7 changed files with 137 additions and 60 deletions

View file

@ -648,11 +648,21 @@ static float lookup_want(uint64_t jobid)
return 0.0f;
}
/* SESSION_FROM - the `from` an allocation decided in a session that began at
* `begin_ns` (epoch nanoseconds) carries: the session start in whole
* seconds, floor division (libxce-alloc-preason-equality Decision 8;
* scheduler.c's sched_make_primary_alloc_() stamps it, and in simulation
* mode the session starts at the recorded beginRound). This file's
* capacity-aware stand-in allocator stamps its DISPATCH allocations the
* same way, so the recording it produces carries the value a live replay
* of that round reproduces. */
#define SESSION_FROM(begin_ns) ((uint64_t)(begin_ns) / 1000000000ULL)
/* Builds the wire-shaped xce_job_alloc_t a DISPATCH decision carries -- same
* field shape test_sim_verify.c's own make_test_alloc()/make_test_host_alloc()/
* make_test_job_alloc() establish. */
static xce_job_alloc_t* make_dispatch_alloc(uint64_t jobid, const char* host,
float value)
float value, uint64_t from)
{
xce_alloc_t* res = (xce_alloc_t*)calloc(1, sizeof(*res));
xce_host_alloc_t* h = (xce_host_alloc_t*)calloc(1, sizeof(*h));
@ -670,7 +680,7 @@ static xce_job_alloc_t* make_dispatch_alloc(uint64_t jobid, const char* host,
res->reserve = strdup("run");
res->instid = 1;
res->value = value;
res->from = 0;
res->from = from;
res->duration = 0;
allocs[0] = res;
@ -798,7 +808,12 @@ static void* capacity_aware_allocator_thread_fn(void* arg)
job->accounts = make_charge_account(WORKER_NAME, want);
sched_commit_job_alloc(core, job);
job->allocs = make_dispatch_alloc(jobid, WORKER_NAME, want);
/* Stamp `from` exactly as sched_make_primary_alloc_()
* (scheduler.c) stamps a real allocation: the deciding
* session's start in whole seconds. */
job->allocs = make_dispatch_alloc(
jobid, WORKER_NAME, want,
SESSION_FROM(core->session_start));
picker->picker_iface->on_dispatch(picker, jobid);
decision = make_dispatch_decision(job->allocs);