fix(scheduler): record each pend reason once per job (bug-1927)

The scheduler appended one NO_RESOURCE/MATCH_FAIL entry per host per
placement plan, so a pending parallel job carried plans x hosts copies
(~93k entries in the 1000-host bounds test). libxce gains
add_job_preason_once() with a per-context hash index keyed on
(host, resource, code) that keeps first-occurrence order; the
scheduler's three builders use it. add_job_preason() is unchanged for
other callers. The parjob equivalence test now expects each short host
once; the bounds test runs in ~2 s instead of ~19 s.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-10-09 06:30:58 +00:00
parent 6c3393aa86
commit 9f9b63dd24
Signed by untrusted user: rshen
GPG key ID: 80533536B0EB651C
10 changed files with 517 additions and 17 deletions

View file

@ -7,6 +7,7 @@
#include <stdlib.h>
#include "kvmgr.h"
#include "preason.h"
#include "resreq.h"
#include "typemap.h"
#include "xce/types.h"
@ -196,6 +197,11 @@ typedef struct {
xce_sched_alloc_req_t alloc_req;
xce_job_alloc_t* alloc;
xce_pendreason_t* reason;
/* bug-1927: lookup index for reason's lists, so a host re-evaluated by
* every plan of the attempt records each (host, resource, code) once
* (add_job_preason_once(), preason.h). Zeroed by sched_ctx_init(),
* released by sched_ctx_fini(); it never owns reason itself. */
xce_preason_index_t reason_index;
/* Req 9.5: defaults to XCE_ALLOC_NORMAL via sched_ctx_init()'s existing
* memset(ctx, 0, sizeof(*ctx)) -- XCE_ALLOC_NORMAL is the enum's zero
* value, so no explicit assignment is needed. */