ec-image r2: the byte bound is an independent measurement, not the guard's own statement
Browse files at this commita4ec8d50f521a42fa6899c389e19b309a02a03e8Parent: 46c79952 changed files +47 -8
crates/ec-image/tests/fuzz.rsmodified+12 -3
| @@ -563,9 +563,18 @@ fn a_webp_animation_with_many_tiny_frames_over_a_huge_canvas_is_refused_by_the_t | |||
| 563 | // express that: it measures the host's memcpy bandwidth, measured at | 563 | // express that: it measures the host's memcpy bandwidth, measured at |
| 564 | // 0.75-0.89 s on this desktop host against 3.89 s on a server for | 564 | // 0.75-0.89 s on this desktop host against 3.89 s on a server for |
| 565 | // byte-identical decoder work, which is what reddened the old 2 s | 565 | // byte-identical decoder work, which is what reddened the old 2 s |
| 566 | - // ceiling. The decoder's own total budget is the machine-independent | 566 | + // ceiling. |
| 567 | - // ceiling: it refuses once the running total crosses it, so nothing | 567 | + // |
| 568 | - // beyond it can have been allocated. | 568 | + // The byte bound is an INDEPENDENT measurement, not the guard's own |
| 569 | + // tally: `AllocBudget::spend` sums DECLARED byte counts at chosen call | ||
| 570 | + // sites, while `counting_allocations` sums the ACTUAL `layout.size()` of | ||
| 571 | + // every allocation (and every realloc's full new size, so an | ||
| 572 | + // incrementally grown Vec contributes more than its final size), plus the | ||
| 573 | + // refusal's own formatting inside the measured window. So "refused at the | ||
| 574 | + // budget" does NOT by itself mean "allocated no more than the budget" -- | ||
| 575 | + // and this test's red proof (one clone moved past the spend -> 5.12e9 | ||
| 576 | + // bytes against the 4.29e9 budget) is exactly the check that the two | ||
| 577 | + // stay close enough for the budget to be a meaningful ceiling. | ||
| 569 | let budget = ec_image::Limits::default().max_total_alloc as u64; | 578 | let budget = ec_image::Limits::default().max_total_alloc as u64; |
| 570 | let data = one_pixel_animated_webp(16000, 16000, 64); | 579 | let data = one_pixel_animated_webp(16000, 16000, 64); |
| 571 | let (err, allocated) = counting_allocations(|| { | 580 | let (err, allocated) = counting_allocations(|| { |
lanes/ecimagewallclock.report.mdmodified+35 -5
| @@ -47,9 +47,25 @@ Bound the work in **bytes allocated**, measured with a thread-local counting | |||
| 47 | global allocator in the test binary, against the decoder's *own* limit | 47 | global allocator in the test binary, against the decoder's *own* limit |
| 48 | (`Limits::default().max_total_alloc`). No clock survives in these tests. | 48 | (`Limits::default().max_total_alloc`). No clock survives in these tests. |
| 49 | 49 | ||
| 50 | -The ceiling is not a fitted constant — it is the budget the guard enforces, so | 50 | +The ceiling is not a fitted constant — it is the guard's own `max_total_alloc`. |
| 51 | -the assertion states the invariant directly: a decode that has refused at the | 51 | +It is also NOT the same statement as the guard's meaning, and this lane's own |
| 52 | -total budget cannot have allocated more than the total budget. | 52 | +red proof is the counterexample: `AllocBudget::spend` sums DECLARED byte |
| 53 | +counts at chosen call sites, while `counting_allocations` sums the ACTUAL | ||
| 54 | +`layout.size()` of every allocation (and every realloc's full new size, so an | ||
| 55 | +incrementally grown `Vec` contributes about 2N rather than N), and the refusal | ||
| 56 | +path itself formats an `Error` inside the measured window. The two diverge: | ||
| 57 | +relocating `spend` one clone later produced 5120024246 bytes against a | ||
| 58 | +4294967296-byte budget — a decode that refused "at the total budget" allocated | ||
| 59 | +more than it. So the byte bound is best described as an independent | ||
| 60 | +measurement of actual work performed, and the red proofs as tests of the | ||
| 61 | +correspondence between the declared budget and actual allocation — which is | ||
| 62 | +the stronger and more accurate framing. | ||
| 63 | + | ||
| 64 | +The tally deliberately keeps measuring total allocation TRAFFIC (realloc's | ||
| 65 | +full new size included) rather than switching to net-live bytes or deltas: | ||
| 66 | +the host difference this class exists to measure is memcpy bandwidth, which | ||
| 67 | +is a property of traffic, not of liveness. So the divergence above is the | ||
| 68 | +measurement doing its job, not an error to close. | ||
| 53 | 69 | ||
| 54 | Two additional facts fall out of the byte measurement for free: | 70 | Two additional facts fall out of the byte measurement for free: |
| 55 | 71 | ||
| @@ -83,6 +99,13 @@ memory-subsystem difference, not just a clock difference: | |||
| 83 | 1. 16 CPU spinners on 12 cores + 6 `dd oflag=direct` memory hammers. | 99 | 1. 16 CPU spinners on 12 cores + 6 `dd oflag=direct` memory hammers. |
| 84 | 2. The same plus 24 spinners and 10 more hammers (1-minute load average 46). | 100 | 2. The same plus 24 spinners and 10 more hammers (1-minute load average 46). |
| 85 | 101 | ||
| 102 | +The concurrency figures (spinners, hammers, load average 46) are INFERRED from | ||
| 103 | +elapsed times, not recorded alongside the runs: the shell wedged, the load ran | ||
| 104 | +as detached processes, and the two coincide by construction, not by measurement. | ||
| 105 | +The elapsed numbers above are the measured part; the process counts are the | ||
| 106 | +reconstructed part, and the distinction matters because a reader could | ||
| 107 | +otherwise take "load 46 while the test ran" as a single observed fact. | ||
| 108 | + | ||
| 86 | Under mechanism 1, decode elapsed measured **1.46–1.75 s**; under mechanism 2, | 109 | Under mechanism 1, decode elapsed measured **1.46–1.75 s**; under mechanism 2, |
| 87 | **2.42 / 6.30 / 7.31 / 8.91 / 9.26 / 9.34 s**. That range straddles and then | 110 | **2.42 / 6.30 / 7.31 / 8.91 / 9.26 / 9.34 s**. That range straddles and then |
| 88 | clears the old 2000 ms ceiling, so the old assertion is reproduced failing | 111 | clears the old 2000 ms ceiling, so the old assertion is reproduced failing |
| @@ -128,7 +151,10 @@ written for, and the byte bound does. | |||
| 128 | 151 | ||
| 129 | A second mutation (guard spent only on the first frame, so it never trips at | 152 | A second mutation (guard spent only on the first frame, so it never trips at |
| 130 | all) was killed by the memguard cgroup at 10 GiB — SIGKILL before any | 153 | all) was killed by the memguard cgroup at 10 GiB — SIGKILL before any |
| 131 | -assertion, i.e. unbounded work as intended. | 154 | +assertion. That is evidence about the MUTATION's severity, not a red proof of |
| 155 | +the byte bound: the byte assertion never ran, and the memguard cgroup would | ||
| 156 | +catch an unbounded process with or without this lane. The first mutation is | ||
| 157 | +the only red proof of the bound. | ||
| 132 | 158 | ||
| 133 | ### Non-vacuity | 159 | ### Non-vacuity |
| 134 | 160 | ||
| @@ -170,4 +196,8 @@ allocations, and needs no arm/disarm flag. | |||
| 170 | relative path from the worktree cwd; reverted there with | 196 | relative path from the worktree cwd; reverted there with |
| 171 | `git checkout -- crates/ec-image/tests/fuzz.rs` and redone against the | 197 | `git checkout -- crates/ec-image/tests/fuzz.rs` and redone against the |
| 172 | absolute worktree path. The primary checkout is clean apart from the | 198 | absolute worktree path. The primary checkout is clean apart from the |
| 173 | - untracked `.wt/` directory. | ||
| \ No newline at end of file | \ No newline at end of file | ||
| 199 | + untracked `.wt/` directory. | ||
| 200 | +- For the record, `crates/ec-image` is now clock-free for this class: the only | ||
| 201 | + remaining `elapsed()` uses feed `eprintln` rather than assertions, and the | ||
| 202 | + one sub-millisecond comparison that remains is on GIF frame-delay metadata, | ||
| 203 | + not on measured time. | ||
| \ No newline at end of file | \ No newline at end of file | ||