Skip to content

Make BufferAllocator track how much it goes over its limit - #310

Open
lkdvos wants to merge 4 commits into
mainfrom
ld-buffer-growth
Open

lkdvos wants to merge 4 commits into
mainfrom
ld-buffer-growth

Conversation

@lkdvos

@lkdvos lkdvos commented Oct 4, 2026

Copy link
Copy Markdown
Member

This is a small fix for a subtle mistake I made where the buffer offset is not increased when it overflows and has to allocate. The reason I did that originally was that I felt like that way the remaining space might still be used for subsequent contractions, but in hindsight this is probably a bit of a mistake, since that means that the sizehint will only slowly increase.

For example, if I have a capacity of 10, and then allocate 100 times a size-100 vector and then reset, the buffer will resize to 10+100 the first time, and repeating this to 110+100, etc. Instead here, we keep track of what the total usage was, and will immediately resize to 10+100*100.

…locator`

`tensoralloc` only advanced `buffer.offset` for temporaries that fit, so later requests
in the same pass started from too low an offset and `max_offset` underestimated the peak.
The buffer then kept growing by a sliver on many consecutive passes, each time
reallocating the whole buffer. Advancing the offset on overflow as well makes
`max_offset` exact after a single pass, so a repeated allocation pattern converges after
one warm-up pass and the buffer is never reallocated afterwards.

The JLArray tests define pointer-based `dataids` for `JLArray`, as `CuArray` and
`ROCArray` do: with a warm buffer, disjoint temporaries share its storage and were
otherwise falsely reported as aliased.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/implementation/allocator.jl 95.86% <100.00%> (-0.04%) ⬇️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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