Size against 4 Mbps: peaks break the scsi profile; DMA steal is not free
User clarified the bandwidth figure is 4 Mbps (488 KB/s), not 4 MB/s -- ~8x
tighter than the previous commit reasoned against. Two consequences, plus a
correction to session 1.
1. The scsi profile committed in f0f2f80 DOES NOT FIT. Its mean is a
comfortable 52% of the pipe but it PEAKS at 96.4% (470.8 KB/s on scene
00020), and a frame that arrives late is a dropped frame, not a slow one.
Peak/mean is 1.4-1.9x even on 1.2-1.7s clips. Sizing a real-time stream on
the mean was the error. Flagged in STATUS rather than silently retuned,
because the fix is rate control, not a lower lam.
This promotes ratectl.py -- written in session 2, never wired into
encode.py -- from a loose end to the highest-value work in the repo. It is
worth a full step on the quality ladder (lam=25 -> lam=10, +0.7/+1.2 dB)
because it allows sizing for the mean instead of the peak.
2. Pixel-exact is off the table at this bandwidth: lam=0 needs 92-97% of the
pipe. The previous commit's "if SCSI sustains >=800 KB/s, ship transparent"
conclusion only applies at roughly double the user's figure.
3. FINDINGS 5 said that because transfers are DMA, streaming "costs essentially
no CPU" and the 68000 is "nearly idle". That is wrong. The HD63450 steals
~8 clocks per 16-bit word: 10-20% of the machine at the rates the profiles
now use, on top of a 38% full-frame blit. Bandwidth and CPU are one budget.
Adds tools/encoder/profile_gen.py, which derives lam FROM a bandwidth figure
(accounting for audio, peak/mean and DMA steal) instead of reading it off the
knee of the RD curve, and docs/BENCHMARK.md covering how to actually measure
the subsystem -- including why MAME cannot answer the bandwidth question and
would be the same class of error as the FINDINGS 4 traps.
The 4 Mbps figure is user-supplied and its provenance is not recorded; every
profile now hangs off it.
Claude-Session: https://claude.ai/code/session_01194oWYW8DQXK1SZ2DnChW6
This commit is contained in:
@@ -450,3 +450,64 @@ now sit at 110 and 280 KB/s, close enough to the folklore ceilings that the
|
||||
error bars matter, and **if SCSI sustains >=800 KB/s the correct `scsi` profile
|
||||
is lam=0 — pixel-exact video.** Whether this port ships transparent or lossy on
|
||||
SCSI is now waiting on one measurement.
|
||||
|
||||
## 18. Peak-to-mean burstiness — the mean was hiding the problem
|
||||
|
||||
Prompted by the user clarifying that the bandwidth figure is **4 Mbps = 488 KB/s**,
|
||||
not 4 MB/s. That is ~8x tighter than what 17 was reasoning against, and it
|
||||
changes the answer.
|
||||
|
||||
Per-frame instantaneous rate (video + 7.8 KB/s audio), 12 fps:
|
||||
|
||||
| scene | lam | mean | p90 | **max** | peak/mean | max as % of 488 KB/s |
|
||||
|---|---|---|---|---|---|---|
|
||||
| 00010 | 60 | 95.0 | 127.3 | 138.8 | 1.46 | 28.4% |
|
||||
| 00010 | 10 | 198.9 | 266.1 | 284.0 | 1.43 | 58.2% |
|
||||
| 00020 | 60 | 115.8 | 155.4 | 222.3 | 1.92 | 45.5% |
|
||||
| 00020 | 10 | 255.9 | 391.2 | **470.8** | 1.84 | **96.4%** |
|
||||
|
||||
**The `scsi` profile as committed in f0f2f80 does not fit 4 Mbps.** Its mean is a
|
||||
comfortable 52% of the pipe, but it peaks at 96.4% — and a frame that arrives
|
||||
late is a *dropped frame*, not a slow one. Sizing a real-time stream on the mean
|
||||
is the mistake; peak/mean is 1.4-1.9x on 1.2-1.7s clips and will be worse across
|
||||
a full scene.
|
||||
|
||||
Two ways out, and only one is good:
|
||||
- Size for the peak: `lam=25`, mean 194 KB/s. Costs a full step of quality.
|
||||
- **Rate-control to the mean and carry a leaky bucket:** `lam=10` fits, and buys
|
||||
back +0.7 dB (00020) / +1.2 dB (00146).
|
||||
|
||||
`ratectl.py` was written in session 2 but **never wired into `encode.py`**. This
|
||||
demotes that from a loose end to the highest-value unfinished work in the repo.
|
||||
|
||||
## 19. Cycle-stealing DMA is not free DMA — 5 was wrong
|
||||
|
||||
FINDINGS 5 concluded "because it's DMA, streaming costs essentially no CPU —
|
||||
this stacks with the 8% blit utilisation. The 68000 really is nearly idle."
|
||||
|
||||
The HD63450 steals bus cycles from the 68000 at roughly 8 clocks per 16-bit word:
|
||||
|
||||
| stream | words/s | clocks/s | CPU stolen | + full-frame blit |
|
||||
|---|---|---|---|---|
|
||||
| 110 KB/s | 56,320 | 450,560 | 4.5% | 42.8% |
|
||||
| 250 KB/s | 128,000 | 1,024,000 | 10.2% | 48.5% |
|
||||
| 450 KB/s | 230,400 | 1,843,200 | 18.4% | 56.7% |
|
||||
| 488 KB/s | 249,856 | 1,998,848 | 20.0% | 58.3% |
|
||||
|
||||
At the rates the profiles now use, streaming costs **10-20% of the machine**.
|
||||
Still affordable — nothing here breaks — but **bandwidth and CPU are one budget,
|
||||
not two**, and any future headroom argument has to spend from both. The
|
||||
"nearly idle" framing should not be reused.
|
||||
|
||||
(The 8 clocks/word figure is session 1's ESTIMATE from HD63450 timing, not a
|
||||
measurement. It is the weakest link in this table.)
|
||||
|
||||
## 20. Where the profiles should come from
|
||||
|
||||
`tools/encoder/profile_gen.py` now derives lam from a bandwidth figure rather
|
||||
than from the shape of the RD curve, accounting for audio, peak/mean, and
|
||||
reporting DMA steal. Full benchmarking methodology — and why MAME cannot answer
|
||||
the bandwidth question — is in `docs/BENCHMARK.md`.
|
||||
|
||||
The 4 Mbps figure itself is **user-supplied and its provenance is not recorded**.
|
||||
Every profile now hangs off it, so it is worth pinning down.
|
||||
|
||||
Reference in New Issue
Block a user