High-Throughput Concurrency Review Specification
Audit multi-threaded code patches for race conditions, deadlocks, and shared-state synchronization issues.
Use this specification template when evaluating mission-critical pull requests that handle parallel processing or shared memory. It guides a deep code review targeting thread safety and lock contention.
Role: Principal Distributed Systems Engineer with fifteen years of experience in thread safety, lock contention, and high-throughput actor systems.
Context
- Target codebase repository: {{target_repository}}
- Threading model in use: {{concurrency_model}}
- Source code patch under review: {{critical_code_diff}}
- Production target performance: {{throughput_target}}
- Persistence and backing state layer: {{state_storage_engine}}
Task
Produce a concurrency review specification that inspects critical race conditions, deadlocks, and shared-state mutations to guarantee zero data corruption under peak load.
Method
- Trace all mutex acquisitions and released locks across the call graph in {{critical_code_diff}}.
- Evaluate re-entrancy risks and potential lock inversion scenarios between worker threads.
- Analyze memory visibility, cache coherence, and volatile reads against {{concurrency_model}}.
- Inspect atomic operations and compare-and-swap loops for livelock vulnerabilities.
- Audit interaction patterns with {{state_storage_engine}} for transaction isolation anomalies.
- Verify thread-safe lifecycle handling during graceful shutdown and context cancellation.
- Benchmark potential lock contention bottlenecks against the {{throughput_target}} benchmark.
Constraints
- MUST specify exact line-level references for all identified race hazard vectors.
- MUST NOT recommend coarse-grained global locks as acceptable remediation paths.
- Include precise lock-ordering rules for multi-resource acquisitions.
- Restrict recommendations to idioms native to {{concurrency_model}}.
Output format
- Concurrency Threat Matrix (Table: Component, Hazard Type, Risk Severity, Blast Radius)
- Synchronization Flow Analysis (Numbered step-by-step lock lifecycle evaluation)
- Remediation Code Specifications (Diff-style pseudocode with lock semantics)
- Performance Impact Summary (Max 250 words on {{throughput_target}} viability)
Self-review
- Verified all lock paths identify potential deadlock inversion chains?
- Confirmed state interactions with {{state_storage_engine}} account for non-repeatable reads?
- Checked that line references directly correspond to {{critical_code_diff}}?
- Ensured recommendations maintain lock-free invariants where applicable?
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.