Skip to content

plan: print every placement term, and a switch to A/B the slab shrink (#885) - #899

Merged
JustVugg merged 1 commit into
devfrom
diag/pin-budget
Aug 9, 2026
Merged

plan: print every placement term, and a switch to A/B the slab shrink (#885)#899
JustVugg merged 1 commit into
devfrom
diag/pin-budget

Conversation

@JustVugg

@JustVugg JustVugg commented Aug 8, 2026

Copy link
Copy Markdown
Owner

@mohamedmastouri2000-boop's follow-up on #885 says #869 was half a fix. The measurement that established that took fourteen instrumented runs on a 128 GB host to recover numbers this engine already had in registers.

g64  cap raised 8->31   (v1.4.0: 31, v1.5.0: 17)   the width fix landed
E8   cap raised 8->45   (v1.4.0: 46, v1.5.0: 17)

g64  RSS  105.8 -> 64.1 -> 84.67 GB               and stopped there
E8   RSS  106.5 -> 47.5 -> 75.6  GB

This PR does not attempt the remaining fix. It makes the remaining fix decidable.

The line only printed when the clamp bit

if(pin_bytes+1.0<planned_pin)
    fprintf(stderr,"[PIN] auto: %.1f GB plan capped to %.1f GB ...")

So "the reserve was zero" and "the reserve did not bind" were indistinguishable from outside — and those are the two hypotheses anyone debugging placement is choosing between. It now prints every term, every time:

[PIN] auto: budget X GB | plan Y GB (conf C, N selections) |
      LRU reserve Z GB (cap K/layer x W MB/row-set) |
      max_pin M GB -> pinning P GB  [CAPPED by the LRU reserve]

A reserve near the budget means the pin is starved by a reservation the LRU may never claim — it is demand-filled and only allocates on a miss. That is the open half of #885, and it is now visible at a glance instead of by inference.

@mohamedmastouri2000-boop asked for exactly this, twice, before anyone acted on it. That is the actual lesson here.

COLI_SLAB_SHRINK=0

#869 introduced the only new allocator work in that change and stated the cost was unmeasured. #885 then measured it, on the arm that has it:

v1.4.0 g64   1.21, 1.23              spread 0.02
v1.5.0 g64   1.00, 1.01              spread 0.01
dev    E8    1.43, 1.43              spread 0.00
dev    g64   1.12 .98 1.11 .97 1.05  spread 0.15, bimodal

Every arm on that box replicates to ≤0.02 except the one that is new. Reallocating 19–38 MB per crossed row is an mmap/munmap plus page faults on first touch — a per-run effect, which is what bimodal looks like.

The switch restores grow-only so the hypothesis can be A/B'd without a rebuild. It re-introduces the slab migration, so the per-row cap becomes optimistic again: a diagnostic, not a supported configuration, and it says so on stderr when set.

A duplicate symbol, from a merge of mine

91:  static int g_metal_enabled;   // #587, unconditional, with a comment
                                  // explaining why it must be outside the ifdef
100: static int g_metal_enabled;   // the original, still inside #ifdef COLI_METAL

Two tentative definitions the linker merges — no warning, no symptom, green CI. I verified #587's colibri.c changes were all gated behind g_metal_enabled, which was true, and did not check whether the symbol was already there. Removed; the unconditional one stays.

Tests

test_cap_mixed_width gains case E, which exercises the switch by setting g_slab_shrink directly. It has to: the variable is read from the environment in main(), which the test does not run — so exporting COLI_SLAB_SHRINK would have proved nothing, and on the first attempt it did exactly that, passing identically with the switch on and off.

E. shrink OFF: 892928 B -> 892928 B (must not move)
E. shrink ON : 892928 B -> 450560 B (must come down)

make check: 388 tests, 0 failures.

Refs #885, #869, #815, #587

🤖 Generated with Claude Code

…#885)

#885's follow-up says #869 was half a fix, and the measurement that
established that took fourteen instrumented runs on a 128 GB host to
recover numbers this engine already had in registers.

    g64  cap raised 8->31   (v1.4.0: 31, v1.5.0: 17)   the width fix landed
    E8   cap raised 8->45   (v1.4.0: 46, v1.5.0: 17)

    g64  RSS  105.8 -> 64.1 -> 84.67 GB               and stopped there
    E8   RSS  106.5 -> 47.5 -> 75.6  GB

THE LINE ONLY PRINTED WHEN THE CLAMP BIT

    if(pin_bytes+1.0<planned_pin)
        fprintf(stderr,"[PIN] auto: %.1f GB plan capped to %.1f GB ...")

So "the reserve was zero" and "the reserve did not bind" were
indistinguishable from outside -- and those are the two hypotheses anyone
debugging placement is choosing between. @mohamedmastouri2000-boop asked
for exactly this, twice, before anyone acted on it. It now prints every
term, every time:

    [PIN] auto: budget X GB | plan Y GB (conf C, N selections) |
          LRU reserve Z GB (cap K/layer x W MB/row-set) |
          max_pin M GB -> pinning P GB  [CAPPED by the LRU reserve]

budget is what expert_avail() left; plan is 0.5*budget*confidence; reserve
is what #815 holds back for the demand-filled LRU; max_pin is budget minus
reserve. A reserve near the budget means the pin is starved by a
reservation the LRU may never claim, which is the open half of #885 and is
now visible at a glance instead of by inference.

COLI_SLAB_SHRINK=0

#869 introduced the only new allocator work in that change and said the
cost was unmeasured. #885 then measured it, on the arm that has it:

    v1.4.0 g64   1.21, 1.23              spread 0.02
    v1.5.0 g64   1.00, 1.01              spread 0.01
    dev    E8    1.43, 1.43              spread 0.00
    dev    g64   1.12 .98 1.11 .97 1.05  spread 0.15, bimodal

Every arm on that box replicates to <=0.02 except the one that is new.
Reallocating 19-38 MB per crossed row is an mmap/munmap plus page faults on
first touch, which is a per-run effect, which is what bimodal looks like.
The switch restores grow-only so the hypothesis can be A/B'd without a
rebuild. It re-introduces the slab migration, so the per-row cap becomes
optimistic again -- a diagnostic, not a supported configuration, and it
says so on stderr when set.

A DUPLICATE SYMBOL, FROM A MERGE OF MINE

    91:  static int g_metal_enabled;     (#587, unconditional, with a comment
                                          explaining why it must be outside)
    100: static int g_metal_enabled;     (the original, still inside #ifdef)

Two tentative definitions the linker merges, so no warning, no symptom, and
green CI. I verified #587's colibri.c changes were all gated behind
g_metal_enabled -- which was true -- and did not check whether the symbol
was already there. Removed; the unconditional one stays.

TESTS

test_cap_mixed_width gains case E, which exercises the switch by setting
g_slab_shrink directly. It has to: the variable is read from the
environment in main(), which the test does not run, so exporting
COLI_SLAB_SHRINK would have proved nothing -- and on the first attempt it
did exactly that, passing identically with the switch on and off.

    E. shrink OFF: 892928 B -> 892928 B (must not move)
    E. shrink ON : 892928 B -> 450560 B (must come down)

make check: 388 tests, 0 failures.

Refs #885, #869, #815, #587

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@JustVugg
JustVugg merged commit 549f9f1 into dev Aug 9, 2026
17 checks passed
@JustVugg
JustVugg deleted the diag/pin-budget branch August 9, 2026 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant