Skip to content

Drop a per-call closure allocation in the bipermutedimsopadd! axis check#196

Merged
mtfishman merged 1 commit into
mainfrom
mf/check-input-alloc
Jul 1, 2026
Merged

Drop a per-call closure allocation in the bipermutedimsopadd! axis check#196
mtfishman merged 1 commit into
mainfrom
mf/check-input-alloc

Conversation

@mtfishman

Copy link
Copy Markdown
Member

Summary

Removes a per-call heap allocation in check_input for bipermutedimsopadd!. The axis check built its comparison tuple with ntuple(d -> op(axes(src, perm[d])), ndims(dest)), whose index closure captures runtime values (op, src, perm) and so is heap-allocated on every call. Mapping over the permutation tuple directly with map(p -> op(axes(src, p)), perm) is unrolled over the concrete tuple and allocates nothing, and is equivalent because ndims(dest) == length(perm) is already checked just above. A 2x2 permutedimsadd! drops from 2 allocations (64 B) to 1 (16 B).

## Summary

Removes a per-call heap allocation in `check_input` for `bipermutedimsopadd!`. The axis check built its comparison tuple with `ntuple(d -> op(axes(src, perm[d])), ndims(dest))`, whose index closure captures runtime values (`op`, `src`, `perm`) and so is heap-allocated on every call. Mapping over the permutation tuple directly with `map(p -> op(axes(src, p)), perm)` is unrolled over the concrete tuple and allocates nothing, and is equivalent because `ndims(dest) == length(perm)` is already checked just above. A 2x2 `permutedimsadd!` drops from 2 allocations (64 B) to 1 (16 B).
@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.07%. Comparing base (5e7700e) to head (f0bd869).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #196      +/-   ##
==========================================
- Coverage   83.38%   83.07%   -0.31%     
==========================================
  Files          22       22              
  Lines         650      650              
==========================================
- Hits          542      540       -2     
- Misses        108      110       +2     
Flag Coverage Δ
docs 27.84% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

@mtfishman mtfishman merged commit 94ac951 into main Jul 1, 2026
20 of 21 checks passed
@mtfishman mtfishman deleted the mf/check-input-alloc branch July 1, 2026 18:53
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