Experiment: 260fbdd
rad experiment show 260fbdd0bfc43312e5c94de4572344793b00c891
by ee@did:key:z6MkvsiybCuk1WDZhh2aXDx7NTiZejKgWZygMNsUuXDMNvVQ · Apr 11 15:03 2026
use raw().references_glob for namespace heads
Measurements
MetricBaselineThe benchmark measurement of the unmodified codeCandidateThe code with the proposed optimization appliedDeltaThe performance change from baseline to candidate
index_page_latency (ms) primary298.767 ms (n=1)230.934 ms (n=1)-22.70%
index_page_bytes (bytes) secondary83284.000 bytes (n=1)83284.000 bytes (n=1)0.00%
Annotations
hypothesisrepo.references() still walks every ref under storage and parses namespaces; libgit2 reference_glob narrows to refs/namespaces/*/refs/heads/* at the backend
profile_signaliter-2 branches_count block still measured 127ms; total refs walked was much larger than branches of interest. Glob-filtered walk cuts the per-ref work to near-zero for the 80% of refs that aren't heads.
what_worked-22.7% latency. Skipping Ref::try_from eliminated ~65ms/render of ref-type parsing + oid resolution on refs we immediately discard (cobs, sigrefs, identity).
Base CommitThe starting commit before the optimization was applied6a059e78c6bac10696c5721ee003b97afb0a8fbd
Candidate CommitThe code with the proposed optimization applied2a67cf54d0bc8bc2ce056adaca992502cd315476
Configoptimize.yaml
Diff
~ cc-httpd/src/html.rs
@@ -14,7 +14,7 @@ const INDEX_CACHE_TTL: u64 = 30;
14 static INDEX_CACHE: std::sync::LazyLock<Mutex<Option<(Instant, String)>>> = 15 std::sync::LazyLock::new(|| Mutex::new(None)); 16 use radicle::node::AliasStore; 17-use radicle::storage::{ReadRepository, ReadStorage}; 17+use radicle::storage::{ReadRepository, ReadStorage, WriteRepository}; 18 use radicle_experiment::benchmark::{Criteria, OptimizeConfig}; 19 use radicle_experiment::state::Measurement; 20 use radicle_experiment::{Experiments, is_improvement, is_regressed};
@@ -269,7 +269,6 @@ fn branch_is_outdated(
269 main_tip: radicle::git::Oid, 270 branch_tip: radicle::git::Oid, 271 ) -> bool { 272- use radicle::storage::WriteRepository; 272 if main_tip == branch_tip { 273 return false; 274 }
@@ -2133,26 +2132,20 @@ pub(crate) fn index_page_inner(
2132 // metric is reachable from the tip. Same definition as the repo 2133 // page branches table. 2134 // 2136- // Walk `repo.references()` directly instead of `repo.remotes()`. 2137- // `.remotes()` loads `SignedRefs` per peer (signature verification, 2138- // identity checks) which is the dominant cost of rendering this page 2139- // at ~1.4ms per peer and ~1.3s across a seed's full peer set. We 2140- // only need (namespace, refname, tip) for the counting logic, which 2141- // `.references()` returns directly from a single libgit2 ref walk. 2142- // The difference vs signed-refs is that `.references()` sees every 2143- // ref file under `refs/namespaces/<peer>/refs/heads/*`, including 2144- // any transiently-unsigned ones — acceptable for an approximate 2145- // index-page count. 2135+ // Walk `refs/namespaces/*/refs/heads/*` directly via libgit2's 2136+ // reference glob. `repo.references()` iterates *every* ref 2137+ // (sigrefs, cobs, identity, canonical heads, …) and calls 2138+ // `Ref::try_from` on each, which resolves the ref and parses the 2139+ // namespace prefix — wasted work on refs we filter out. We also 2140+ // skip `repo.remotes()` entirely because it loads per-peer 2141+ // `SignedRefs`, doing signature verification we don't need. 2142 let mut branches_count = 0usize; 2147- if let Ok(refs_iter) = repo.references() { 2148- for r in refs_iter.filter_map(Result::ok) { 2149- if r.namespace.is_none() { 2143+ if let Ok(mut refs_iter) = repo.raw().references_glob("refs/namespaces/*/refs/heads/*") { 2144+ while let Some(Ok(reference)) = refs_iter.next() { 2145+ let Some(tip_raw) = reference.target() else { 2146 continue; 2151- } 2152- if !r.name.as_str().starts_with("refs/heads/") { 2153- continue; 2154- } 2155- let tip_oid = r.oid; 2147+ }; 2148+ let tip_oid: radicle::git::Oid = tip_raw.into(); 2149 let Some(branch_config) = 2150 radicle_experiment::benchmark::config_at_commit(&repo, tip_oid) 2151 else {
Environment
Buildtrue
Teststrue
Archaarch64
OSDarwin 14.6.1
CPUApple M2
Agentpi-autoresearch / pi
Filescc-httpd/src/html.rs