fix(scheduler): load shared resource values from the snapshot (bug-1923)

xce_scheduler --sim started with no shared resource pool when the shared
values came only from the recording's SnapshotEntry (license value=(none)),
so jobs needing a shared resource pended instead of dispatching. Two
defects caused it:

- Load side (snapshot_load.c): a resval was treated as shared only when
  rv->host == NULL. The capnp round trip (write_snapshot_entry ->
  decode_SnapshotEntry) reads a NULL host back as "", so every shared
  resval in a .replay file was skipped. A NULL or empty host now means
  the shared pool; only a named host marks per-worker data.
- Save side (snapshot.c, snapshot_wire.c): core->sharedInst and each
  worker's resvals were walked with i < .count. zarray_t.count is the
  number of filled slots, not the highest idx + 1, and both arrays are
  sparse by resource idx, so higher-index values were dropped from the
  snapshot. Both loops are now bounded by .caps, as repl_info.c already is.

New test test_snapshot_sparse_resvals.c covers the in-memory save/load,
the empty-host load, and the real sched_record_start() -> .replay ->
sched_sim_driver_start() round trip.

Regenerated fixtures/repl_trace_baseline/set_output.replay: its mid-run
snapshot now carries license, limit=cluster_slots and each worker's
limit=host_slots, which the old writer dropped (all other fixtures
unchanged).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-10-08 08:09:29 +00:00
parent 4f951f2b52
commit 16616d9688
Signed by untrusted user: rshen
GPG key ID: 80533536B0EB651C
7 changed files with 453 additions and 5 deletions

View file

@ -58,6 +58,12 @@
* written and never regenerated. Review the fixture diff before
* committing.
*
* bug-1923 regenerated set_output.replay only: the snapshot `set output`
* takes mid-run now carries the shared resvals (license,
* limit=cluster_slots) and each worker's limit=host_slots value, which the
* old snapshot writer dropped. Every other fixture is unchanged (a regen
* also rewrites recordingStartWall, which the comparison ignores).
*
* Link style: the real scheduler_srcs list (minus main.c), same as
* test_sim_e2e_limit_visibility.c, which this file's replay writer
* follows (resources, license value and limit config baked into the