Commit 3cc4985
authored
feat(metrics): cross-source de-dup win metrics (time & quantity) (#60)
* feat(metrics): cross-source de-dup win metrics (time & quantity)
Record, at each de-dup contest, which source delivered first and by how
much, so the edge feed can be shown winning against the original/public
sources in both quantity and latency.
- arbiter: StalenessFloor/WindowedDedup return an `Admit` outcome that
reports the first cross-source follower per tick/trade as a `Contest`
carrying the winning publisher and lead_ns. `Arbiter::emit` records
dz_quote_lead_ns / dz_trade_lead_ns (histograms) and dz_trades_admitted_total.
- shred: ShredPacket carries the source group + monotonic arrival; DedupWindow
tracks the winning group and returns DropDuplicate{winner_group, lead_ns} on
cross-group duplicates, recorded as dz_shred_wins_total / dz_shred_lead_ns.
- metrics: histogram_vec helper + shared ns lead-time buckets.
Recording is always on (only the HTTP exposer stays gated by --metrics-bind),
matching the existing metrics design. lead_ns is clamped non-negative.
* fix(metrics): split dedup lead histograms by loser; test the emit arm
Address PR #60 review:
- M1: add a `loser` label to dz_quote_lead_ns / dz_trade_lead_ns so an
edge-vs-edge mirror race ({winner="edge",loser="edge"}) no longer dilutes
the headline edge-vs-public margin ({winner="edge",loser="public"}) in
multi-mirror deployments. The loser is the non-leader `publisher` already
in scope at the Contest arm, so no `Admit` change is needed.
- M2: add end-to-end tests through `Arbiter::emit` asserting a cross-source
contest reaches the lead-time histogram (right winner/loser child) and the
drop counter, not just returns Admit::Contest. Keyed on per-test unique
venues so absolute counts hold without #[serial].
* test(shred): exercise cross-group DropDuplicate metric end-to-end
Close the M2 gap on the shred side from the PR #60 review: the forwarder
tests wrapped packets via ShredPacket::from(Vec<u8>) (sentinel group), so
every duplicate was same-group and the Action::DropDuplicate ->
dz_shred_wins_total / dz_shred_lead_ns arm was never driven end-to-end.
Add run_forwarder_packets (explicit per-packet group + arrival) and a test
sending the same shred from two distinct groups, asserting one forward plus
the win-count and lead-time histogram deltas for the group that delivered
first.1 parent 700ef13 commit 3cc4985
7 files changed
Lines changed: 779 additions & 147 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
10 | 27 | | |
11 | 28 | | |
12 | 29 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
21 | 44 | | |
22 | 45 | | |
23 | 46 | | |
| |||
51 | 74 | | |
52 | 75 | | |
53 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
54 | 80 | | |
55 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
56 | 94 | | |
57 | 95 | | |
58 | 96 | | |
| |||
111 | 149 | | |
112 | 150 | | |
113 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
114 | 160 | | |
115 | 161 | | |
116 | 162 | | |
| |||
146 | 192 | | |
147 | 193 | | |
148 | 194 | | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
149 | 212 | | |
150 | 213 | | |
151 | 214 | | |
| |||
220 | 283 | | |
221 | 284 | | |
222 | 285 | | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
223 | 292 | | |
224 | 293 | | |
225 | 294 | | |
226 | 295 | | |
227 | 296 | | |
228 | 297 | | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
229 | 317 | | |
230 | 318 | | |
231 | 319 | | |
| |||
361 | 449 | | |
362 | 450 | | |
363 | 451 | | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
364 | 466 | | |
365 | 467 | | |
366 | 468 | | |
| |||
411 | 513 | | |
412 | 514 | | |
413 | 515 | | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
414 | 529 | | |
415 | 530 | | |
416 | 531 | | |
| |||
424 | 539 | | |
425 | 540 | | |
426 | 541 | | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
427 | 547 | | |
428 | 548 | | |
429 | 549 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
214 | | - | |
| 213 | + | |
| 214 | + | |
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| |||
0 commit comments