perf(skippy): fault in native output buffers before the device writes them #2994
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 381 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.356
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2994"
general
weight: 0.35
jaredwy
What
skippy-runtime now hands native code output buffers whose pages are already resident. This covers state exports, KV pages and stage activation frames. A new
native_output_bufferreplaces thevec![0_u8; n]allocations inkv_pages.rs,activation.rsandactivation/iteration_execution.rs. It writes one byte per page with a volatile write after allocating.Why
vec![0; n]maps large allocations lazily, so the first write to each page is the GPU's device-to-host copy. On DGX Spark (GB10, integrated, pageable memory access) that copy page-faults its way through the buffer. Device-to-host bandwidth by destination, measured on a Spark:| Copy | Resident buffer | Fresh
callocbuffer ||---|---|---|
| 13 MiB | 52 GB/s | 0.70 GB/s |
| 64 MiB | 53 GB/s | 0.16 GB/s |
| 256 MiB | 54 GB/s | 3.8 GB/s |
Serving a 12.5k-token prompt, nsys showed about 2 s of every prefill spent in these copies before the first token: the state export for the prefix cache. GPU kernels took about 4.3 s of the 6.6 s. Split serving copies stage activation frames into the same kind of buffer. Its slow (~150 MB/s) KV copies likely have the same cause, but I did not measure split serving.
Result
Served prefill on a DGX Spark, same machine,
mesh-llm serve, speculation off, tok/s:| Model | Prompt | Before | After |
|---|---|---|---|
| Qwen3.6-35B-A3B UD-Q4_K_M | 1.6k | 1831 | 2343 (+28%) |
| | 12.5k | 2009 | 2660 (+32%) |
| Qwen3.6-27B Q4_K_M | 1.6k | 590 | 807 (+37%) |
| | 12.5k | 582 | 847 (+46%) |
Agent loops gain the most, because each turn exports the conversation's state for the prefix cache. Qwen3.6-35B-A3B, append-style loop, time to first token per turn:
| History | Turn | Before | After |
|---|---|---|---|
| 6k tokens | first | 3.06 s | 1.96 s |
| | later (cache hit) | 1.56–1.69 s | 0.64–0.69 s |
| 12k tokens | first | 5.68 s | 3.89 s |
| | later (cache hit) | 2.48–2.76 s | 0.72–0.76 s |
Qwen3.6-27B, same loop:
| History | Turn | Before | After |
|---|---|---|---|
| 6k tokens | first | 11.2 s | 7.3 s |
| | later (cache hit) | 4.05–4.39 s | 0.62–0.76 s |
| 12k tokens | first | 21.6 s | 14.6 s |
| | later (cache hit) | 7.4–8.5 s | 0.83–1.09 s |
Decode is unchanged (35B-A3B 64.7 vs 66.3; 27B 12.2 vs 12.3). Served prefill now runs at 90–94% of
llama-bench's rate on the same build.Tests
cargo test -p skippy-runtimepasses (479), and clippy is clean. The new helper has a unit test.🤖 Generated with Claude Code
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
Refactor
Updated internal buffer handling for generation, iteration, and state export operations.
* Output sizing, retries, truncation, status handling, and returned values remain unchanged. This update does not change user-facing functionality or behavior. No new features or changes to available operations are included.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->