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

@ -699,36 +699,32 @@ test_sim_verify_no_false_mismatch_after_live_dispatch_and_later_confirmation(
* 1-task job's TEST_RESREQ ("rusage[mem=1]", auto-injected 1 slot per
* task) actually requests.
*
* sim_verify_alloc_eq() (sim_verify.c) compares xce_alloc_t
* field-by-field, including instid and duration -- both must match
* EXACTLY what the real seqjob_allocator()->sched_make_allocs()-
* >make_alloc() chain (scheduler.c) will independently produce for
* this exact fixture, not arbitrary placeholders:
* - instid=1: sched_get_id() returns core->nextid++, and core.c
* initializes nextid to 1 (core.c:127) -- this fixture's job is
* the FIRST (and only) allocation ever made against this fresh
* core, so it is deterministically the first ID issued.
* job_alloc_eq() (xcealloc.h, via sim_verify.c's sim_decision_eq())
* compares xce_alloc_t field-by-field, excluding only instid -- so
* duration and from must match EXACTLY what the real
* seqjob_allocator()->sched_make_allocs()->make_alloc() chain plus
* sched_make_primary_alloc_()'s session stamp (scheduler.c) will
* independently produce for this exact fixture, not placeholders:
* - duration=-1: seqjob_allocator.c's own sched_make_allocs() call
* passes a NULL duration array ("FIXME: no duration now"), so
* sched_make_allocs() (scheduler.c) always defaults every entry's
* duration to -1 today.
* `from` (wall-clock time(NULL), set unconditionally by make_alloc()
* itself) is left at whatever value make_alloc() happens to stamp it
* with here -- it no longer needs to agree with the live path's own
* call. bug-1838-followup removed `from` from sim_verify_alloc_eq()'s
* comparison entirely (sim_verify.c): it is a real-wall-clock
* reservation-start stamp, not part of a decision's semantic identity,
* and comparing it made --sim-verify false-flag every genuine
* live-dispatched decision replayed more than a wall-clock second away
* from its own recording. What used to be accepted same-second-window
* flakiness here is now a non-issue by construction. */
* - from=ROUND1_BEGIN_NS / 10^9: every allocation is stamped with
* its deciding session's start in whole seconds (libxce-alloc-
* preason-equality Decision 8), and in simulation mode the session
* starts at the recorded beginRound. make_alloc()'s own time(NULL)
* default is therefore overwritten below.
* instid=1 is kept realistic (sched_get_id() returns core->nextid++,
* and this is the first allocation made against a fresh core) even
* though the comparison ignores it. */
{
const uint64_t ROUND1_BEGIN_NS = 2000ULL;
xce_alloc_t* a = make_alloc((char*)"slots", NULL, 1, 1.0,
-1);
xce_alloc_t** allocs = make_allocs(1, a);
xce_host_alloc_t* h = make_host_alloc((char*)WORKER_NAME, 1, allocs);
xce_host_alloc_t** hallocs = make_host_allocs(1, h);
xce_job_alloc_t* alloc = make_job_alloc(TEST_JOBID, 1, hallocs);
xce_alloc_t** allocs;
xce_host_alloc_t* h;
xce_host_alloc_t** hallocs;
xce_job_alloc_t* alloc;
sched_dispatch_decision_t dispatch;
replay_decision_t d_dispatch;
replay_decision_t* decisions[1];
@ -737,18 +733,24 @@ test_sim_verify_no_false_mismatch_after_live_dispatch_and_later_confirmation(
struct capn_segment* cs;
ReplaySession_ptr sp;
a->from = ROUND1_BEGIN_NS / 1000000000ULL;
allocs = make_allocs(1, a);
h = make_host_alloc((char*)WORKER_NAME, 1, allocs);
hallocs = make_host_allocs(1, h);
alloc = make_job_alloc(TEST_JOBID, 1, hallocs);
memset(&dispatch, 0, sizeof(dispatch));
dispatch.alloc = alloc;
memset(&d_dispatch, 0, sizeof(d_dispatch));
d_dispatch.body_which = ReplayDecision_body_dispatch;
d_dispatch.body.dispatch = &dispatch;
d_dispatch.ts = 2000ULL;
d_dispatch.ts = ROUND1_BEGIN_NS;
decisions[0] = &d_dispatch;
memset(&session, 0, sizeof(session));
session.begin_round = 2000ULL;
session.begin_round = ROUND1_BEGIN_NS;
session.decisions = decisions;
session.n_decisions = 1;
session.summary = NULL;