99 lines
4.5 KiB
Python
Executable File
99 lines
4.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Amdahl sensitivity study only: 0.33.8 measured baseline, 0.34.0 not measured.
|
|
|
|
No synthetic RPS is described as benchmarked RustProxy throughput. Amdahl uses
|
|
RPS_new = RPS_old / (1 - eligible_cost_fraction * fraction_eliminated).
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
from pathlib import Path
|
|
|
|
# Verified medians reproduced from the supplied 0.33.8 evidence. Cache OFF.
|
|
BASELINE = [
|
|
("reverse_proxy", 1040, 29334.12, 170610.16, False),
|
|
("reverse_proxy", 65536, 20735.07, 35393.29, False),
|
|
("reverse_proxy", 1048576, 4461.19, 2730.23, False),
|
|
("www", 1040, 24906.20, 351605.13, False),
|
|
("www", 65536, 20856.67, 203709.91, True),
|
|
("www", 1048576, 2833.71, 12611.49, True),
|
|
]
|
|
|
|
# WWW scenarios: share of per-request service time due to file copy/read;
|
|
# assume sendfile removes HALF of that part, not the full service time.
|
|
WWW_SHARES = {"low": 0.20, "middle": 0.40, "high": 0.60}
|
|
COPY_COST_REMOVED = 0.50
|
|
# Proxy independent optimization: hypothetical reduction in *total* request
|
|
# service time, modeling removal of redundant response-frame mutex, nothing else.
|
|
PROXY_TIME_SAVED = {"low": 0.01, "middle": 0.03, "high": 0.05}
|
|
|
|
|
|
def run() -> dict:
|
|
items = []
|
|
for kind, payload_bytes, rust_rps, nginx_rps, eligible in BASELINE:
|
|
baseline_ratio = rust_rps / nginx_rps
|
|
row = {
|
|
"kind": kind,
|
|
"bytes": payload_bytes,
|
|
"baseline_version": "0.33.8",
|
|
"baseline_rust_rps": rust_rps,
|
|
"baseline_nginx_rps": nginx_rps,
|
|
"baseline_of_nginx_pct": round(100 * baseline_ratio, 2),
|
|
"factor_to_match_nginx": round(nginx_rps / rust_rps, 2),
|
|
"sendfile_eligible_only_if_plain_linux_http1_1_no_cache_no_compression": eligible,
|
|
"scenarios": {},
|
|
}
|
|
for level in ("low", "middle", "high"):
|
|
if kind == "www" and eligible:
|
|
saved_fraction = WWW_SHARES[level] * COPY_COST_REMOVED
|
|
elif kind == "reverse_proxy":
|
|
saved_fraction = PROXY_TIME_SAVED[level]
|
|
else:
|
|
saved_fraction = 0.0
|
|
simulated_rps = rust_rps / (1.0 - saved_fraction)
|
|
row["scenarios"][level] = {
|
|
"modeled_total_time_saved_pct": round(100 * saved_fraction, 2),
|
|
"simulated_rps": round(simulated_rps),
|
|
"simulated_rps_gain_pct": round(100 * (simulated_rps / rust_rps - 1), 2),
|
|
"simulated_of_nginx_pct": round(100 * simulated_rps / nginx_rps, 2),
|
|
"simulated_remaining_gap_to_nginx_pct_points": round(
|
|
100 * (1 - simulated_rps / nginx_rps), 2
|
|
),
|
|
}
|
|
items.append(row)
|
|
return {
|
|
"kind": "HYPOTHETICAL_AMDAHL_SENSITIVITY_NOT_A_BENCHMARK",
|
|
"comparison": "Existing 0.33.8 measurements (5 runs, cache off) vs measured nginx",
|
|
"not_measured": "0.34.0 server performance and sendfile syscall/runtime correctness",
|
|
"conditions": [
|
|
"Identical CPU and network assumptions to supplied 0.33.8 baseline",
|
|
"WWW zero-copy is limited to Linux, cleartext HTTP/1.1, GET >=64KiB, no cache, range, transform, compression or TLS",
|
|
"WWW low/middle/high: file-copy contributes 20%/40%/60% of total request time; modeled sendfile eliminates 50% of that component",
|
|
"Reverse proxy low/middle/high: removing response-frame mutex saves a hypothetical 1%/3%/5% of total service time",
|
|
"These fractions are chosen sensitivity parameters; not measured or inferred from profiling",
|
|
"No change is assumed for WWW 1040B or out-of-scope protocol paths",
|
|
"No network saturation, TLS record processing, queueing, origin latency, filesystem cache misses, CPU contention or concurrency effects modeled",
|
|
"No additional speedup due to cache-retention changes is assumed",
|
|
],
|
|
"formula": "RPS_sim = RPS_0.33.8 / (1 - fraction_of_total_service_time_eliminated)",
|
|
"entries": items,
|
|
}
|
|
|
|
|
|
def main() -> None:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--output", type=Path, help="write JSON to this file")
|
|
args = parser.parse_args()
|
|
payload = json.dumps(run(), indent=2, ensure_ascii=False) + "\n"
|
|
if args.output:
|
|
args.output.parent.mkdir(parents=True, exist_ok=True)
|
|
args.output.write_text(payload)
|
|
print(f"wrote {args.output}")
|
|
else:
|
|
print(payload)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|