]> git.hungrycats.org Git - bees/commitdiff
scan_next: tag re-centered Plan B plans in the log
authorZygo Blaxell <bees@furryterror.org>
Thu, 9 Jul 2026 18:50:45 +0000 (14:50 -0400)
committerZygo Blaxell <bees@furryterror.org>
Sat, 10 Oct 2026 19:00:03 +0000 (15:00 -0400)
Add a "pivot" marker to the plan: line for destinations of a re-centered Plan B
(prefer-canonical-src pivoted the star onto a higher-ref whole-extent duplicate),
so re-centered plans are greppable when validating the pivot against a run.
DstPlan carries an m_pivoted flag set on each pivoted destination at build time;
the plan: line prints " pivot" when it is set.  Document the tag in running.md.

Assisted-by: Claude-Code:claude-opus-4-8
Assisted-by: Claude-Code:claude-opus-5-5
docs/running.md
src/bees-scan-next.cc

index 3541cc5924fbe7781cffc9220a3122dace1a8e5a..a154fce17a1c773b5dfca4c8f2b4d4297d24ee6c 100644 (file)
@@ -154,3 +154,8 @@ chosen plan and why it was chosen:
     do-nothing is exactly `0`.  A destination with a large `refs` and a negative
     `debt` was worth rewriting because the space it frees outweighs the cost of
     moving its references.
+  * `pivot` — present when this destination belongs to a re-centered plan: with
+    `rewrite.prefer-canonical-src`, the dedupe star was pivoted onto a
+    higher-reference whole-extent duplicate, so this destination (possibly the
+    scanned extent itself) is being deduped onto that canonical rather than the
+    scanned extent surviving as the source.
index 5b0c5caf72a0f6ff7b27c736a9440047bf07f4b7..21cd8849721ab995cfd44a1d67bff32878742245 100644 (file)
@@ -1726,6 +1726,11 @@ struct DstPlan {
        /// m_dst_ref_count (read fresh at build): if this is ~0 while that is large,
        /// the planner priced the dst against a stale/reduced ref view.
        uint64_t m_sel_refs_created = 0;
+       /// True when this dst belongs to a re-centered Plan B (prefer-canonical-src
+       /// pivoted the star onto a higher-ref whole-extent duplicate, so this dst —
+       /// possibly the former start — is deduped onto that canonical).  Logged as a
+       /// "pivot" tag on the "plan:" line so re-centered plans are greppable.
+       bool     m_pivoted = false;
 };
 
 /// Output of the planner: a list of accepted dst plans plus
@@ -2989,7 +2994,8 @@ scan_next_execute_dst_plan(const shared_ptr<BeesContext> &ctx,
                << to_hex(dst.bytenr()) << "} ["
                << bar << "] refs " << dst_plan.m_dst_ref_count
                << " rc " << dst_plan.m_sel_refs_created
-               << " debt " << setprecision(1) << dst_plan.m_space_debt);
+               << " debt " << setprecision(1) << dst_plan.m_space_debt
+               << (dst_plan.m_pivoted ? " pivot" : ""));
 
        return true;
 }
@@ -3305,6 +3311,7 @@ scan_next_build_extent_plan(
                                                dp->m_space_debt       = winner_space_debt;
                                                dp->m_sel_refs_created = winner_refs_created;
                                                dp->m_dst_ref_count = dst.refs(diag_layer)->size();
+                                               dp->m_pivoted = true;
                                                out.m_total_cost += dp->m_cost;
                                                out.m_dst_plans.push_back(std::move(*dp));
                                        }