spec: re-probe stale full chains when shorter chains pay

A profitable shorter chained lookup returned before the stale full-size check, so the full chain could stay excluded for good
although the policy re-probes stale sizes in the other selection paths (#1252). Check a confident stale full size before
returning the profitable shorter chain. The 300-round policy, the EMA, the header and plain lookup are unchanged; a regression
test covers the bounded re-probe spacing and the MTP confidence gate.
This commit is contained in:
Hulk authored and Niko1221 committed 2026-10-09 03:18:07 +02:00
1 parent a26fcbcdba
commit 71eaee17b9
2 files changed
+30 -2

No files matched your search

+6 -2
View File
@@ -128,9 +128,13 @@ int DraftPolicy::chain(int t_mtp, double p_mtp, int k_avail, int match) const {
const double r = (e0 + p_mtp * gain) / cost_ms(t_mtp + k);
if (r > best) { best = r; best_k = k; }
}
if (best_k > 0 && best > base * (1.0 + margin_)) return best_k;
// as choose(): a size whose cost is only guessed is tried a few times when the continuation looks likely
const int t_full = t_mtp + kmax;
if (best_k > 0 && best > base * (1.0 + margin_)) {
// As choose(): a profitable shorter chain must not keep a stale full size from being measured again.
if (best_k < kmax && p_mtp * c >= 0.6 && stale(t_full)) return kmax;
return best_k;
}
// as choose(): a size whose cost is only guessed is tried a few times when the continuation looks likely
if ((cost_n_[t_full] < kProbes || stale(t_full)) && p_mtp * c >= 0.6) return kmax;
return 0;
}