Skip to content

add job-assignment internals notes and heap sampler - #90

Open
Alistair-Afton wants to merge 3 commits into
DFHack:masterfrom
Alistair-Afton:job-assignment-doc
Open

Alistair-Afton wants to merge 3 commits into
DFHack:masterfrom
Alistair-Afton:job-assignment-doc

Conversation

@Alistair-Afton

Copy link
Copy Markdown

Summary

Detailed writeup of DF's job-assignment mechanism, reverse engineered on v0.53.16 Steam via external memory sampling:

  • doc/job-assignment.rst — the auction model (units push job_applicationst bids into world.jobs.job_application_heap, a 2000-slot max-heap drained within each assignment pass), observed value bands (~9.5k baseline, ~1.05M continuation, ~20M for do_now and unit-sourced need jobs), the task-interruption taxonomy (need thresholds, claim races, outbidding, killjob exceptions), reproduction methodology, and open questions. Field offsets and constants are documented with how-to-re-derive instructions.

  • job_heap_sampler.py — a standalone ReadProcessMemory sampler that catches the heap mid-pass (it lives sub-millisecond inside the tick, invisible to in-process Lua polling). Prints each batch with resolved unit ids and posting→job metadata. Constants are parameterized per-build.

Related: DFHack/df-structures#908 adds the field-level comments to df.job.xml; DFHack/dfhack#3245 is the motivating issue (do_now granularity).

Test plan

  • Sampler verified against live DF v0.53.16 (captured 13 non-empty batches, all documented bands reproduced)
  • RST builds clean (single-file doc, no toctree changes needed)

doc/job-assignment.rst documents DF's job-assignment auction
(job_applicationst bids into a max-heap; do_now adds ~20000000;
continuation ~1000000; posting recycling), observed value bands, the
task-interruption taxonomy, and reproduction methodology for v0.53.16.

job_heap_sampler.py samples world.jobs.job_application_heap via
ReadProcessMemory, catching the sub-millisecond in-tick passes that
in-process Lua cannot observe.
Per ab9rf (DFHack/scripts#1639): handle_job_applications pushes a
crashlog minidump entry of type 0xf on entry and removes it on exit,
giving a deterministic in-process signal for when an auction pass is
running. Also records its v0.50.16 Steam/Windows address and the
version-relocation caveat.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant