11#!/usr/bin/env python3
2- """Print a side-by-side comparison of SlimeRPC vs Ray benchmark CSVs.
2+ """Print a side-by-side comparison of SlimeRPC, Ray (and optionally Pulsing) benchmark CSVs.
33
44Usage:
5- python rpc_bench_compare.py [--slime results/slime_rpc.csv] [--ray results/ray_rpc.csv]
5+ python rpc_bench_compare.py \\
6+ [--slime results/slime_rpc.csv] \\
7+ [--ray results/ray_rpc.csv] \\
8+ [--pulsing results/pulsing_rpc.csv] # optional
69"""
710
811import argparse
@@ -22,10 +25,15 @@ def label(size: int) -> str:
2225def main ():
2326 default_dir = os .path .join (os .path .dirname (__file__ ), ".." , "results" )
2427 parser = argparse .ArgumentParser (
25- description = "Compare SlimeRPC vs Ray benchmark results"
28+ description = "Compare SlimeRPC vs Ray (and optionally Pulsing) benchmark results"
2629 )
2730 parser .add_argument ("--slime" , default = os .path .join (default_dir , "slime_rpc.csv" ))
2831 parser .add_argument ("--ray" , default = os .path .join (default_dir , "ray_rpc.csv" ))
32+ parser .add_argument (
33+ "--pulsing" ,
34+ default = None ,
35+ help = "Optional Pulsing CSV; if omitted, Pulsing columns are skipped." ,
36+ )
2937 args = parser .parse_args ()
3038
3139 for path in (args .slime , args .ray ):
@@ -37,25 +45,43 @@ def main():
3745 slime = load (args .slime )
3846 ray_r = load (args .ray )
3947
40- common = sorted (set (slime ) & set (ray_r ))
48+ pulsing = None
49+ if args .pulsing :
50+ if not os .path .exists (args .pulsing ):
51+ print (f"Missing Pulsing results file: { args .pulsing } " )
52+ print ("Run rpc_bench_pulsing.py first, or omit --pulsing." )
53+ return
54+ pulsing = load (args .pulsing )
55+
56+ common = set (slime ) & set (ray_r )
57+ if pulsing is not None :
58+ common &= set (pulsing )
59+ common = sorted (common )
4160 if not common :
42- print ("No overlapping sizes between the two result files." )
61+ print ("No overlapping sizes between the result files." )
4362 return
4463
4564 col = 12
46- sep = "-" * (
47- 10 + 1 + col + 1 + col + 1 + col + 1 + col + 1 + col + 1 + col + 1 + 12
48- )
49-
5065 print (
5166 "\n ┌─ Avg Latency (µs) ─────────────────────────────────────────────────────────┐"
5267 )
53- header = (
54- f"{ 'Size' :<10} | "
55- f"{ 'Slime avg' :>{col }} | { 'Slime p99' :>{col }} | { 'Slime BW' :>{col }} | "
56- f"{ 'Ray avg' :>{col }} | { 'Ray p99' :>{col }} | { 'Ray BW' :>{col }} | "
57- f"{ 'Speedup' :>10} "
58- )
68+
69+ if pulsing is not None :
70+ header = (
71+ f"{ 'Size' :<10} | "
72+ f"{ 'Slime avg' :>{col }} | { 'Slime p99' :>{col }} | { 'Slime BW' :>{col }} | "
73+ f"{ 'Puls avg' :>{col }} | { 'Puls p99' :>{col }} | { 'Puls BW' :>{col }} | "
74+ f"{ 'Ray avg' :>{col }} | { 'Ray p99' :>{col }} | { 'Ray BW' :>{col }} | "
75+ f"{ 'S/Pul' :>10} | { 'S/Ray' :>10} "
76+ )
77+ else :
78+ header = (
79+ f"{ 'Size' :<10} | "
80+ f"{ 'Slime avg' :>{col }} | { 'Slime p99' :>{col }} | { 'Slime BW' :>{col }} | "
81+ f"{ 'Ray avg' :>{col }} | { 'Ray p99' :>{col }} | { 'Ray BW' :>{col }} | "
82+ f"{ 'S/Ray' :>10} "
83+ )
84+ sep = "-" * len (header )
5985 print (header )
6086 print (sep )
6187
@@ -66,17 +92,36 @@ def main():
6692 ray_avg = float (ray_r [size ]["avg_us" ])
6793 ray_p99 = float (ray_r [size ]["p99_us" ])
6894 ray_bw = float (ray_r [size ]["bw_gbps" ])
69- speedup = ray_avg / sl_avg # >1 means SlimeRPC is faster
95+ sp_ray = ray_avg / sl_avg # >1 means SlimeRPC is faster than Ray
96+
97+ if pulsing is not None :
98+ pu_avg = float (pulsing [size ]["avg_us" ])
99+ pu_p99 = float (pulsing [size ]["p99_us" ])
100+ pu_bw = float (pulsing [size ]["bw_gbps" ])
101+ sp_pul = pu_avg / sl_avg # >1 means SlimeRPC is faster than Pulsing
102+ print (
103+ f"{ label (size ):<10} | "
104+ f"{ sl_avg :>{col }.1f} | { sl_p99 :>{col }.1f} | { sl_bw :>{col }.3f} | "
105+ f"{ pu_avg :>{col }.1f} | { pu_p99 :>{col }.1f} | { pu_bw :>{col }.3f} | "
106+ f"{ ray_avg :>{col }.1f} | { ray_p99 :>{col }.1f} | { ray_bw :>{col }.3f} | "
107+ f"{ '%.2fx' % sp_pul :>10} | { '%.2fx' % sp_ray :>10} "
108+ )
109+ else :
110+ print (
111+ f"{ label (size ):<10} | "
112+ f"{ sl_avg :>{col }.1f} | { sl_p99 :>{col }.1f} | { sl_bw :>{col }.3f} | "
113+ f"{ ray_avg :>{col }.1f} | { ray_p99 :>{col }.1f} | { ray_bw :>{col }.3f} | "
114+ f"{ '%.2fx' % sp_ray :>10} "
115+ )
70116
117+ print (sep )
118+ if pulsing is not None :
71119 print (
72- f"{ label (size ):<10} | "
73- f"{ sl_avg :>{col }.1f} | { sl_p99 :>{col }.1f} | { sl_bw :>{col }.3f} | "
74- f"{ ray_avg :>{col }.1f} | { ray_p99 :>{col }.1f} | { ray_bw :>{col }.3f} | "
75- f"{ '%.2fx' % speedup :>10} "
120+ "S/Pul = Pulsing avg latency / SlimeRPC avg latency (>1 means SlimeRPC wins)"
76121 )
77-
78- print ( sep )
79- print ( "Speedup = Ray avg latency / SlimeRPC avg latency (>1 means SlimeRPC wins)" )
122+ print (
123+ "S/Ray = Ray avg latency / SlimeRPC avg latency (>1 means SlimeRPC wins)"
124+ )
80125 print ()
81126
82127
0 commit comments