EngineeringWhy Janus Runs Three Concurrent Generations, Not Five
· Janus
- #local-llm
- #mlx
- #performance
- #kv-cache
Janus, the local-LLM coding IDE I built, limits how many generation requests can go to the local model server at once. These are called generation slots, and sub-agents (workers), chat and verification share them. When the slots are full, no new worker is created, and the reason is recorded.
The default started at 5 and is now 3. This post covers why it changed and what has to happen before it goes up again.
Why it started at 5
When slots were added, the choice between 3 and 5 was left open and 5 shipped. It wasn't picked for a reason.
Why it went down to 3
The machine is an Apple Silicon Mac with 48GB of memory, running Qwen3.8 27B reduced (quantized) to 4-bit. Three things were checked.
KV cache is per request
The KV cache stores computations for earlier tokens. Each request gets its own, and I used an estimate of 5 to 12GB per request at a 49K-token worker budget to assess memory headroom. Five requests of that size, plus the model and other processes, increase the risk of swapping.
Requests share one GPU
On Apple Silicon, a single GPU (Metal) does all generation. One request can generate while another waits on a tool, but throughput does not necessarily grow in proportion to the number of generation slots.
MTP also needs checking
MTP (multi-token prediction) predicts several tokens ahead and confirms them in one step. The speedup depends on those predictions holding. When raising the slot count, I would also check whether the MTP benefit and overall throughput hold up.
The direct reason for choosing a lower default came from usage records. Over that cycle, concurrent generation peaked at 3, and the p95 wait for a slot (the longest wait once the slowest 5% are set aside) was 0.012ms. I saw no need for five during that observation window. A measured peak of three does not establish the optimum for every workload.
5 → 3
Default generation slots
3
Measured peak concurrency
0.012ms
Slot wait p95
Raising it is decided by measurement
Along with lowering the default, Janus now shows when slots are actually short. There was already a function for "recalculate slots from GPU memory (VRAM) only when slot waits are a real bottleneck," but nothing called it at runtime, and no wait times were recorded for it to use, so that condition could never become true.
- Each time Janus's scheduler (the part that hands out slots to requests) grants a slot, the actual wait is recorded, up to the last 512. Tool and verification waits are kept out, because frequent tool waits would blur the p95.
- "Increase recommended" appears only when the p95 wait is at least 1 second with at least 10 recorded waits. The operations screen shows this verdict every 2 seconds.
- Only after that recommendation do you raise slots, in settings or with the
JANUS_MODEL_SLOTSenvironment variable. Settings allow 1 to 8.
The first time this ran on the real machine there were only 2 recorded waits, so the verdict was held as "insufficient samples." It followed the rule of not raising slots before the evidence is there.
Summary
With a local model, staying stable within memory came before running many requests at once. The memory estimate and wait records from that window led to a default of 3, and raising it waits until measured wait times show a need.