MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / run_module_benchmark

Function run_module_benchmark

tools/ci/src/keynote_bench.rs:69–121  ·  view source on GitHub ↗
(
    module: &BenchmarkModule,
    cli_path: &Path,
    config_path: &Path,
    server_url: &str,
)

Source from the content-addressed store, hash-verified

67}
68
69fn run_module_benchmark(
70 module: &BenchmarkModule,
71 cli_path: &Path,
72 config_path: &Path,
73 server_url: &str,
74) -> Result<BenchmarkResult> {
75 eprintln!(
76 "Running keynote benchmark against {} module ({})...",
77 module.label, module.module_dir
78 );
79
80 publish_module(module, cli_path, config_path, server_url)?;
81 generate_module_bindings(module, cli_path, config_path)?;
82 seed_accounts(cli_path, config_path, server_url)?;
83 let runs_dir = tempfile::tempdir().context("failed to create temporary benchmark runs directory")?;
84 let transfer_fuel_before = transfer_fuel_total(server_url)?;
85 run_benchmark(module, server_url, runs_dir.path())?;
86 let transfer_fuel_after = transfer_fuel_total(server_url)?;
87 let transfer_fuel_total = transfer_fuel_after - transfer_fuel_before;
88 ensure!(
89 transfer_fuel_total > 0.0,
90 "{} keynote benchmark did not record any fuel for the {TRANSFER_REDUCER} reducer",
91 module.label
92 );
93
94 let result_path = find_result_json(runs_dir.path())?;
95 let result_json = fs::read_to_string(&result_path)
96 .with_context(|| format!("failed to read benchmark result {}", result_path.display()))?;
97 let tps = result_tps(&result_json)?;
98
99 if tps < module.min_tps {
100 eprintln!(
101 "Keynote perf regression for {} module: throughput {tps:.0} TPS < {:.0} TPS\n\nResult JSON:\n{}",
102 module.label, module.min_tps, result_json
103 );
104 bail!(
105 "keynote benchmark throughput for {} module is below threshold",
106 module.label
107 );
108 }
109
110 println!(
111 "Keynote perf check passed for {} module: throughput {tps:.0} TPS >= {:.0} TPS; \
112 {TRANSFER_REDUCER} fuel total {transfer_fuel_total:.0} ({})",
113 module.label,
114 module.min_tps,
115 result_path.display()
116 );
117 Ok(BenchmarkResult {
118 label: module.label,
119 transfer_fuel_total,
120 })
121}
122
123fn publish_module(module: &BenchmarkModule, cli_path: &Path, config_path: &Path, server_url: &str) -> Result<()> {
124 let label = format!("spacetime publish keynote {} module", module.label);

Callers 1

runFunction · 0.85

Calls 9

generate_module_bindingsFunction · 0.85
seed_accountsFunction · 0.85
transfer_fuel_totalFunction · 0.85
run_benchmarkFunction · 0.85
find_result_jsonFunction · 0.85
result_tpsFunction · 0.85
publish_moduleFunction · 0.70
OkFunction · 0.50
pathMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…