]> git.hungrycats.org Git - bees/commitdiff
bench-bees-plan: make operation limits configurable
authorZygo Blaxell <bees@furryterror.org>
Thu, 2 Jul 2026 21:11:46 +0000 (17:11 -0400)
committerZygo Blaxell <bees@furryterror.org>
Sat, 5 Sep 2026 04:04:13 +0000 (00:04 -0400)
The harness hard-coded the default op limits (100 each), which fixes the
search into the collapse-on regime.  To measure the collapse-on vs
collapse-off scaling that governs planner cost, accept two more optional
arguments: a per-type cap (dedupe/copy/hole) and a total cap.  collapse is
on iff both dedupe_max and copy_max are >= total_max, so per=total keeps
it on while per<total forces the O(V^4) fallback.

Defaults are unchanged (100/100), so existing invocations behave as
before; the new arguments only extend the sweep space.  The output line
now echoes the caps and whether collapse is active.

Assisted-by: Claude-Code:claude-opus-4-8
test/bench-bees-plan.cc

index 830c2ebc17106063539e8fe9b5c90158b0c5fa0b..bbc991db9543d7c7636babd613e979fd4500fa26 100644 (file)
@@ -28,6 +28,8 @@ main(int argc, char **argv)
        const uint64_t Nblocks  = argc > 2 ? strtoull(argv[2], nullptr, 10) : 4096;
        const uint64_t MaxLen   = argc > 3 ? strtoull(argv[3], nullptr, 10) : 64;
        const unsigned seed     = argc > 4 ? strtoul(argv[4], nullptr, 10) : 1;
+       const uint64_t PerType  = argc > 5 ? strtoull(argv[5], nullptr, 10) : 100;
+       const uint64_t TotalMax = argc > 6 ? strtoull(argv[6], nullptr, 10) : PerType;
        const uint64_t BS       = 4096;
 
        PlanSearchInputs in;
@@ -50,17 +52,27 @@ main(int argc, char **argv)
        BeesRewritePolicy policy;
        policy.ref_cost    = 53;
        policy.extent_cost = 53;
-       // Default op limits (100 each) stay as-is — the realistic gate.
+       // Op limits configurable to probe collapse-on vs collapse-off scaling:
+       //   PerType applied to dedupe/copy/hole; TotalMax to total.
+       //   collapse is ON iff dedupe_max >= total_max && copy_max >= total_max.
+       policy.m_dedupe_max = PerType;
+       policy.m_copy_max   = PerType;
+       policy.m_hole_max   = PerType;
+       policy.m_total_max  = TotalMax;
+       const bool collapse = PerType >= TotalMax;
 
        const auto t0 = chrono::steady_clock::now();
        const auto res = scan_next_plan_shortest_path(in, policy);
        const auto t1 = chrono::steady_clock::now();
        const double ms = chrono::duration<double, milli>(t1 - t0).count();
 
-       printf("M=%zu Nblocks=%llu MaxLen=%llu  ->  %8.1f ms  %s  "
+       printf("M=%zu Nblocks=%llu MaxLen=%llu per=%llu total=%llu %s  ->  %9.1f ms  %s  "
               "debt=%.0f dedupes=%zu copies=%zu\n",
                M, static_cast<unsigned long long>(Nblocks),
-               static_cast<unsigned long long>(MaxLen), ms,
+               static_cast<unsigned long long>(MaxLen),
+               static_cast<unsigned long long>(PerType),
+               static_cast<unsigned long long>(TotalMax),
+               collapse ? "collapseON " : "collapseOFF", ms,
                res ? "ok    " : "nullopt",
                res ? res->m_debt : 0.0,
                res ? res->m_selected_matches.size() : static_cast<size_t>(0),