"""Exact arithmetic for the independent-queue approximation, not a simulation.""" from fractions import Fraction import json from pathlib import Path import sys SOURCE = "https://conferences.sigcomm.org/co-next/2013/program/p283.pdf" def means(load): if not isinstance(load, Fraction): raise TypeError("load must be an exact Fraction") if not 0 <= load < Fraction(1, 2): raise ValueError("two-copy stationary comparison requires 0 <= load < 1/2") return 1 / (1 - load), 1 / (2 * (1 - 2 * load)) def results(): rows = [] for load in (Fraction(1, 5), Fraction(1, 3), Fraction(2, 5), Fraction(49, 100)): single, double = means(load) rows.append({ "baseline_load": str(load), "duplicated_load": str(2 * load), "single_mean_service_units": str(single), "two_copy_mean_service_units": str(double), "two_copy_over_single": str(double / single), "outcome": "faster" if double < single else "equal" if double == single else "slower", }) return { "schema_version": 1, "evidence_type": "exact arithmetic within a published approximation", "source": SOURCE, "locator": "section 2.1, independence-approximation paragraph and Theorem 1, page 285", "assumptions": [ "Poisson arrivals; identical servers; independent exponential service times", "two immediate copies of every request; neither copy cancelled", "negligible client overhead; stationary queues; mean service time normalized to one", "independent response-time approximation, not exact finite-server queue dynamics", ], "limits": "Not measured storage latency, a queue simulation, a p99 estimate, or a safe operating threshold.", "rows": rows, } if __name__ == "__main__": payload = json.dumps(results(), indent=2) + "\n" if len(sys.argv) == 1: print(payload, end="") elif len(sys.argv) == 3 and sys.argv[1] == "--output": Path(sys.argv[2]).write_text(payload) else: raise SystemExit("usage: redundancy_load.py [--output FILE]")