You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
π§ final review: v0.5.0 β clippy clean, fmt clean, doc fix, version bump
- Suppressed intentional clippy::bind_instead_of_map in benchmarks (and_then
chains are deliberate Result baselines, not candidates for map)
- Fixed "EhContext" -> "Eh" in benchmarks.md (type was renamed)
- Applied cargo fmt across benches and lib.rs
- Bumped version 0.4.1 -> 0.5.0
- Included pending README updates (constructors section, new doc links)
- Included pending loss-types.md stdlib Loss documentation
- Included pending flight-recorder.md navigation link
WARN: Collection Loss impls (Vec, HashSet, BTreeSet, String) have total() ==
zero() β the absorbing element property does not hold. Documented in code
comments and loss-types.md. Monoid identity + associativity are sound.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/benchmarks.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,7 +66,7 @@ Same pattern. Success tracks Result. Partial adds the loss-preservation cost.
66
66
| All Success | 648 ps |
67
67
| All Partial | 6.06 ns |
68
68
69
-
The `EhContext` struct adds zero overhead beyond the loss accumulation itself. Same performance characteristics as raw `eh` chains. The context is a zero-cost coordinator.
69
+
The `Eh` struct adds zero overhead beyond the loss accumulation itself. Same performance characteristics as raw `eh` chains. The context is a zero-cost coordinator.
70
70
71
71
### Loss type combination
72
72
@@ -83,3 +83,5 @@ ConvergenceLoss and RoutingLoss combine in under 1 ns. They're scalar max operat
83
83
Result is a two-state type that optimizes for the fast path by *deleting the middle*. Imperfect is a three-state type that preserves it. The benchmarks say: preservation is free until there's something to preserve. Then it costs 0.65 ns per step.
84
84
85
85
That's not a tax. That's a price. And it buys you the flight recorder that Result said you couldn't have.
86
+
87
+
[Back to README](../README.md) Β· [Flight recorder β](flight-recorder.md) Β· [Pipeline β](pipeline.md)
**`zero()`** β 0.0 entropy, 1.0 gap. One model at 100%.
104
104
**`total()`** β infinite entropy, 0.0 gap. Maximum uncertainty.
105
105
106
+
## Standard library Loss implementations
107
+
108
+
`Loss` is implemented for common standard library types out of the box:
109
+
110
+
### Numeric losses
111
+
112
+
| Type |`combine`|`zero()`|`total()`|
113
+
|------|-----------|----------|-----------|
114
+
|`usize`| saturating add |`0`|`usize::MAX`|
115
+
|`u64`| saturating add |`0`|`u64::MAX`|
116
+
|`f64`| addition (IEEE) |`0.0`|`f64::INFINITY`|
117
+
118
+
### Collection losses
119
+
120
+
Track *what* was lost, not just *how much*.
121
+
122
+
| Type |`combine`|`zero()` / `total()`|
123
+
|------|-----------|----------------------|
124
+
|`Vec<T: Clone>`| append | empty |
125
+
|`HashSet<T: Eq + Hash + Clone>`| union | empty |
126
+
|`BTreeSet<T: Ord + Clone>`| union | empty |
127
+
|`String`| join with `"; "`| empty |
128
+
129
+
> **Limitation:** Collections have no natural absorbing element. `total()` returns the same as `zero()` (empty). The monoid identity and associativity laws hold, but the absorbing property does not. If you need absorbing semantics, use a numeric loss type.
130
+
131
+
### Tuple combinator
132
+
133
+
`(A, B)` where both `A: Loss` and `B: Loss` composes two loss dimensions independently. Each component combines, zeros, and totals on its own.
See the [flight recorder guide](flight-recorder.md) for more composition patterns.
147
+
106
148
## Implementing your own Loss type
107
149
108
150
Implement `Loss` for any domain-specific measurement. The only requirements: `Clone + Default`, the four trait methods, and `combine` must be associative.
0 commit comments