job-system
Use when the user asks about a game engine job system, work stealing, task scheduler, fibers, parallel for, job graph dependencies or engine threading…
от j4flmao★ 47 звёзд на GitHub
Установить job-system в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Parallel Job Systems — Deep Engineering Guide
Purpose
Modern CPUs give you 8–32 cores; a single-threaded Update() leaves them idle. The job system is the backbone that spreads simulation, animation, physics, and render-command generation across cores — transparently, deterministically, and within the frame budget.
Agent Protocol
Trigger
"job system", "work stealing", "task scheduler", "fibers", "parallel for", "job graph", "engine threading".
Input Context
- Language/runtime and core counts on targets
- Workloads to parallelise and their dependencies
- Determinism requirements
Output Artifact
Scheduler design and C++ code. No file unless requested.
Response Format
Scheduler: {work-stealing | fixed queues | fibers}
Graph: {jobs and edges}
Code: {snippet}
Verify: {profiler lanes, contention}
1. Why a Job System
1.1 The Multicore Reality
| Workload | Threads that help | Where it breaks |
|---|---|---|
| Graphics (GPU) | Async compute helps | Raster work is GPU-bound |
| Simulation (physics, AI) | Many cores | Contention on shared state |
| Animation skel + pool | Many cores | Ordering (blend tree) |
| Render command gen | Medium parallel | Sorting at end |
Raw multicore won't help if every thread fights over one lock. Job systems give structured parallel workers: fixed worker threads, work queues, and dependencies.
1.2 One Worker per Core — No Oversubscription
CPU threads: [render thread] [audio thread] [gameplay thread] [worker × N]
Job pool: dependent jobs flushed to workers by the scheduler
Never create a thread per request (std::thread per job → oversubscription plus OS thread-creation cost, typically tens of microseconds each). The scheduler owns N workers = hardware threads − 1 (one for the main/render thread).
2. Job Primitives
2.1 The Job
struct Job {
void (*fn)(JobContext&, void* data); // context = arena, worker_id, frame_data
void* data;
JobHandle dependencies[MaxDeps]; // DAG edges
};
2.2 JobHandle
struct JobHandle {
uint32_t counter; // atomic completion counter
// wait(): busy-wait until counter == 0
};
A job is "done" when its counter drops to 0 (its own + all children). Join is the primitive: JobSystem::Wait(handle) blocks the caller until the group completes.
2.3 The Frame Pattern
// Game frame: dispatch all systems, join at the end
JobHandle hPhysics = jq->dispatch(physicsJobs, kPhysicsJobs);
JobHandle hAnim = jq->dispatch(animJobs, animCount, &hPhysics); // depends
JobHandle hRender = jq->dispatch(renderCmds, kRenderCmds, &hAnim);
jq->wait(&hRender); // one join per frame, not per subsystem
The single join at frame end is what makes job systems cheap — workers run everything in parallel; the main thread only waits once.
3. Scheduling Models
3.1 Central Work Queue (Simple)
One global queue of runnable jobs; workers pop from it (mutex-protected). Fine for a few workers; contention on the shared lock grows with core count, so measure before scaling it up. Simple, deterministic-ish.
class WorkQueue {
std::mutex m; std::deque<std::function<void()>> jobs_;
public:
void push(job j) { lock; jobs_.push_back(j); }
job tryPop() { lock; if empty return {}; pop_front; }
};
3.2 Work Stealing (production schedulers, e.g. TBB, Rayon)
Each worker owns a deque of jobs. The owner pushes and pops at the bottom (LIFO → recently created, cache-hot work); an idle worker steals from the top of a random victim's deque (FIFO → oldest, usually largest chunks), e.g. a Chase-Lev deque.
Worker A deque: [j1, j2, j3] ← A pops j3 (LIFO, hot cache)
Worker B idle: steals j1 (front) ← cache-cold, steal is rare so OK
Benefits: near-linear scaling for embarrassingly-parallel passes, minimal lock contention. Determinism caveat: steal order is random → iteration order varies run to run.
3.3 Level/Chunk Parallelism
Partition a job list into k chunks and dispatch k worker jobs; each handles count/k items. For-loop style:
// parallel_for over [0, n)
void ForEach(uint32_t n, void(*fn)(uint32_t i, void* ctx), void* ctx) {
... dispatch chunk jobs ...
}
parallel_for is the single most-used job primitive (systems, ECS queries, mesh pools).
4. Dependencies & the DAG
4.1 Fine-Grained vs Coarse
| Style | Granularity | Pros | Cons |
|---|---|---|---|
| Coarse (system-level) | whole systems depend on whole systems | super simple, near-deterministic | bubbles (waits) |
| Fine (job-level) | per-job deps | max parallelism | build DAG complexity |
Production engines do both: coarse system phases with fine dependencies inside the phase.
4.2 Diamond / Rectified Joins
AnimPose ──┬──> SkelUpdate ──> RenderNode
Player ─┴──> Camera ──────> ...
Careful: a job with two parents waits for bo
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/dependency-graph.md
- references/determinism.md
- references/fibers-and-async.md
- references/job-profiling.md
- references/parallel-for.md
- references/scheduler-impl.md
FAQ
Что делает скилл job-system?
Use when the user asks about a game engine job system, work stealing, task scheduler, fibers, parallel for, job graph dependencies or engine threading. Produces job system design that fits the frame budget. Not for backend service concurrency (use backend-concurrency-mechanics) or GPU async compute (use render-graph).
Как установить скилл job-system?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл job-system запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
AnthropicGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
webapp-testing
AnthropicToolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
brand-guidelines
AnthropicApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
web-artifacts-builder
AnthropicSuite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…