feat(latency): latency experiments, LATENCY.md, Kalshi's slow-connection recycle

Extension 4. `engineering-challenge latency EXCHANGE OUT.csv` opens 16
connections to the same busy markets and writes every copy of every change;
`scripts/latency/analyse.py` gives each connection's speed, whether it
persists, what keeping the fastest would gain, lateness by address, and lag
with the clock's offset. LATENCY.md writes up four runs: on Polymarket speed
persists but is worth under a millisecond, at the median only; on Kalshi's
demo keeping the fastest pair lowers p99 by 28% and 42%, the threshold
agreed before the runs.

So the collector now recycles a Kalshi connection whose mean lateness stays,
3 minutes running, in the slowest quarter and above twice everyone's, ahead
of its hourly turn. Kalshi's rule measures each duplicate's lateness; the
orchestrator judges once a minute. A duplicate's lag in Polymarket's minute
line is now its "lateness".

Roadmap milestone 7, roadmap/07.
This commit is contained in:
pascal committed 2026-11-12 15:05:25 +01:00
1 parent 1a5bbcd602
commit 515e85941d
22 files changed
+2132 -55

No files matched your search

Generated
+27
View File
@@ -314,6 +314,8 @@ dependencies = [
"serde_json",
"serde_yaml_ng",
"sha1",
"sntpc",
"sntpc-net-std",
"tungstenite",
"ureq",
]
@@ -657,6 +659,12 @@ dependencies = [
"syn 2.0.119",
]
[[package]]
name = "miniloop"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad14b72c9fa5a663d069c582d576e5336995e3fafe7d0965d2bba3db1f98c40c"
[[package]]
name = "miniz_oxide"
version = "0.8.9"
@@ -998,6 +1006,25 @@ version = "1.16.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b3dc8af474f516a851ff4bd12db780f948b9250ad37211e4eec0bccea54e01b"
[[package]]
name = "sntpc"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "294278b134cd7d06d7f22eca970aebe38707864c080f66547f9ad26327534af3"
dependencies = [
"cfg-if",
"miniloop",
]
[[package]]
name = "sntpc-net-std"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "335b2e533977c45a8c909c2297c659942aee18f2319aae29ee6038271d8d0131"
dependencies = [
"sntpc",
]
[[package]]
name = "stable_deref_trait"
version = "1.2.1"