Experiment: 5fb0edf
rad experiment show 5fb0edf02f50b1b26c76d9c9d038d468c9583983
by lftherioslftherios@did:key:z6MkupQHdQky5atyAu9zF8dUu1EavUjckDgCdZLH8y2W8teE · Apr 21 14:47 2026
inline minimal delta extraction in ticker loop, skipping PrimaryMetricView allocations
Measurements
MetricBaselineThe benchmark measurement of the unmodified codeCandidateThe code with the proposed optimization appliedCandidate/Parent ΔThe performance change from baseline to candidate
index_page_latency (ms) primary
median wall-clock latency of cc-httpd index_page_inner render (landing page HTML against local Radicle storage), measured over 15 iterations with 3 warmups
108.434 ms (n=1)107.877 ms (n=1)-0.51%
index_page_bytes secondary61341.000 (n=1)61330.000 (n=1)-0.01% REGRESSED
Annotations
hypothesisPrimaryMetricView::from_experiment always allocates a name String (clone of m.name) and a unit String (via catalog.unit_for) even though the landing-page ticker only consumes delta_str + is_improvement. Inlining the minimal computation saves 2 small allocs per visible experiment per render
what_worked107.9ms vs 108.406ms prior keep (re-measured, -0.47%); cumulative vs segment baseline 108.965ms → 107.9ms (-0.98%). Two independent runs agreed (107.877 / 107.917). The ticker loop is called once per ui-visible experiment across all repos, so savings scale with total experiment count
Base CommitThe starting commit before the optimization was applied438f3669345b62ddaeaca6750811672e67e6de44
Candidate CommitThe code with the proposed optimization appliedf50176c723dbea4c4c676808aa8daa3de0bcabd5
Bench scripta28ada5e27a8
bench_cmd./bench/benchmark.sh
build_cmdcargo build --release -p cc-httpd
Schemav5
Diff
~ cc-httpd/src/html/index.rs
@@ -137,6 +137,12 @@ pub(crate) fn index_page_inner(
137 // Single pass over all_exps: collect ui-visible experiment oids 138 // (for the per-peer branch tip prefilter below) while simultaneously 139 // counting experiments, reproductions, and building ticker rows. 140+ // 141+ // The ticker only needs `delta_str` + `is_improvement` from each 142+ // experiment's primary metric, so inline the minimal computation 143+ // instead of calling `PrimaryMetricView::from_experiment`, which 144+ // always allocates `name` and `unit` Strings that this call site 145+ // discards. 146 let mut visible_tip_oids: std::collections::HashSet<radicle::git::Oid> = 147 std::collections::HashSet::with_capacity(all_exps.len()); 148 for (_id, exp) in &all_exps {
@@ -147,23 +153,26 @@ pub(crate) fn index_page_inner(
153 experiment_count += 1; 154 reproduction_count += exp.reproductions.len(); 155 150- let primary = PrimaryMetricView::from_experiment(exp, &catalog); 151- 152- if primary.is_improvement { 156+ let Some(primary_metric) = exp.metrics.first() else { 157+ continue; 158+ }; 159+ let primary_criteria = catalog.criteria_for(primary_metric); 160+ let is_improvement = 161+ radicle_experiment::is_improvement(primary_metric.delta_pct_x100, primary_criteria); 162+ if is_improvement { 163 improved_count += 1; 164 } 165 156- if primary.has_metric { 157- ticker_items.push(TickerItem { 158- repo_name: name.clone(), 159- description: exp.description.clone().unwrap_or_default(), 160- delta_str: primary.delta_str, 161- improved: primary.is_improvement, 162- created_at: exp.created_at.as_secs(), 163- rid_short: rid_short.clone(), 164- exp_id: _id.to_string(), 165- }); 166- } 166+ let (delta_str, _) = fmt_delta(primary_metric.delta_pct_x100, primary_criteria); 167+ ticker_items.push(TickerItem { 168+ repo_name: name.clone(), 169+ description: exp.description.clone().unwrap_or_default(), 170+ delta_str, 171+ improved: is_improvement, 172+ created_at: exp.created_at.as_secs(), 173+ rid_short: rid_short.clone(), 174+ exp_id: _id.to_string(), 175+ }); 176 } 177 178 if experiment_count == 0 {
Environment
Archaarch64
OSDarwin 26.3.1
CPUApple M1 Max
Agentpi-autoresearch / pi
Filescc-httpd/src/html/index.rs