Skip to content

TreeDB alloc loop: minimize Ironbird execution allocation #3515

Description

@snissn

Goal

Minimize allocation from TreeDB code paths during actual Ironbird execution, with plain-send as the first priority and small-multisend as the second priority.

Done means the active loop process has either landed every reasonable PR-sized allocation reduction visible in accepted Ironbird TreeDB heap profiles, or recorded measured rejections/blockers for the remaining allocator families with enough evidence that continuing would be speculative churn.

Why This Exists

The useful optimization target is not a generic microbenchmark allocation number. The source of truth is accepted Ironbird execution: full-stack TreeDB rows, real Cosmos transaction workloads, heap profiles captured from the validator, and runtime/storage timing from the same run.

Package benchmarks and unified-bench are still required, but only as repro and iteration tools. A loop is not successful unless it reduces the targeted Ironbird TreeDB allocation family, keeps total/TreeDB-focused allocation neutral or better, and does not create a material throughput or ABCI timing regression.

Current Operating Model

Each allocation loop should have its own child issue and scoped PR or measured rejection.

  1. Start from an accepted Ironbird heap profile and rank TreeDB-owned flat alloc_space sites.
  2. Create or update one child issue for the selected allocator family.
  3. Use codex-issue-graph-executor for the child graph state, implementation branch, PR, evidence, and merge gate.
  4. Add or use a focused local repro only after the Ironbird allocator target is confirmed.
  5. Run focused tests and local allocation benchmarks/profiles before macro validation.
  6. Run accepted Ironbird plain-send validation for plain-send targets.
  7. Run accepted Ironbird small-multisend guard when the changed path is shared or when small-multisend is the target.
  8. Merge only if latest-head CI/review gates pass and no material performance regression remains.
  9. If the candidate fails the macro gate, close or mark the child rejected with exact artifacts and move to the next Ironbird-ranked allocator family.

Current Graph State

Active child:

Issue PR State Branch/head Contract surface Current gate
#3566 #3567 draft macro validation running codex/3566-readonly-prepare-clonekey / 3848fabeb9a1fc1ef570bb1fc39a7fe5c6932c98 TreeDB/zipper/read_only_prepare.go, focused tests/benchmarks in TreeDB/zipper plain-send passed allocator gate; small-multisend guard running before PR readiness

Current #3566 target:

Workload Baseline artifact Baseline gomap Target allocator Baseline alloc_space
plain-send TreeDB /mnt/fast4tb/ironbird-3566-current-main-plain-20260706T162213Z/plain-send/treedb/attempt-1 6f2d94def23551ccb1c6bdb35514bc72733d88e0 zipper.(*ReadOnlyPrepareResult).cloneKey 9218.10 MB

Candidate #3567 plain-send result:

Metric Baseline Candidate Delta Decision
total alloc_space 118380.47 MB 110324.47 MB -6.8% pass
TreeDB-focused flat alloc_space 26753.94 MB 18948.87 MB -29.2% pass
ReadOnlyPrepareResult.cloneKey 9218.10 MB no focused samples effectively removed pass
load-window TPS 583.29 578.45 -0.83% neutral within default gate

Recent accepted/rejected loop policy:

  • PR-sized wins should be landed only when accepted Ironbird rows support them.
  • Microbench wins that worsen total Ironbird allocation, TreeDB flat allocation, commit/finalize/check timing, or throughput should be rejected even if the named symbol improves.
  • Prior rejected retention/pool-only loops stay rejected unless a fresh Ironbird profile and a different implementation strategy justify a new child issue.

North-Star Gates

Gate Current standard Required evidence If the gate fails
Target allocator reduction selected TreeDB flat site should materially drop, normally at least 10% unless the issue is explicitly instrumentation/safety-only before/after accepted Ironbird heap profiles with same workload shape and gomap commits fix, reject candidate, or open/link the next measured allocator issue
Total allocation total validator alloc_space should be neutral or lower same heap profiles and total pprof top reject or profile/fix before merge
TreeDB-focused allocation TreeDB-focused flat allocation should be neutral or lower TreeDB-focused pprof summaries reject or profile/fix before merge
Runtime throughput no material TPS regression; default guard is not worse than 1% without explicit acceptance accepted Ironbird load-window metrics with at least a 300s window rerun if noisy; otherwise fix/reject
ABCI/storage timing no material commit/finalize/check regression attributable to the change Ironbird storage_signal_summary and CPU/heap profiles profile/fix or reject before merge
Correctness/CI focused tests, affected package tests, latest-head CI and review gates pass local test logs plus GitHub latest-head checks/reviews do not merge

Scope

Included:

  • TreeDB allocation families visible in accepted Ironbird plain-send and small-multisend heap profiles.
  • Child issues and PRs for allocator families such as read-only prepare key cloning, memtable append-only entry backing, command-WAL payload build/read/decode allocation, batch Set/SetView allocation, value-log compression/buffer allocation, and caching/flush materialization allocation when they are visible in Ironbird profiles.
  • Focused local repros and package benchmarks that explain and validate an Ironbird-observed allocation site.
  • Full-stack TreeDB Ironbird rows for macro-visible candidates.

Excluded:

  • Optimizing microbench-only sites that do not show up in accepted Ironbird execution.
  • Broad rewrites without a ranked Ironbird allocator target.
  • Public API changes, on-disk format changes, durability-policy changes, or legacy slab/value-store concepts unless a future child issue explicitly scopes and justifies them.
  • Opening broad PRs that mix unrelated allocator families.

Branch And PR Policy

  • Work on topic branches.
  • Do not push directly to main.
  • One PR should map to one child allocator loop unless a coordinator comment explicitly changes the graph.
  • PRs must be mergeable before merge: latest-head CI, focused tests, benchmark/profile evidence, and review findings resolved or explicitly rejected with rationale.
  • Codex, Copilot, CodeRabbit, or other review-credit-consuming AI reviews should be requested only after the PR is mature: coherent code, focused tests, required benchmark evidence or rationale, current PR body/status, no known local blockers, and latest-head CI running or green.
  • Material performance regressions are blocking unless minimized and explicitly accepted by the coordinator with evidence.

Required Child Issue Shape

Every child allocation loop must include:

  • The exact Ironbird artifact path and gomap commit that selected the target.
  • The selected TreeDB flat allocator, alloc_space, total alloc_space, TreeDB-focused allocation, TPS, and ABCI timing baseline.
  • The local reproducer or clear rationale if no local reproducer exists.
  • The exact tests and benchmarks required before macro validation.
  • The accepted Ironbird validation command/shape and artifact path.
  • A clear closeout: merged PR with evidence, or rejected candidate with artifacts and next allocator issue.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions