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 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 }
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 {