Skip to content

Add BlockedUnitRangeFirsts/Lasts to avoid allocating#509

Open
dlfivefifty wants to merge 9 commits into
masterfrom
dl/blockedfirstlasts
Open

Add BlockedUnitRangeFirsts/Lasts to avoid allocating#509
dlfivefifty wants to merge 9 commits into
masterfrom
dl/blockedfirstlasts

Conversation

@dlfivefifty

@dlfivefifty dlfivefifty commented Jul 2, 2026

Copy link
Copy Markdown
Member

This introduces a special type to avoid allocations in blockfirsts/blocklengths. It also removes a hack for ranged blocklasts that didn't work when the first index wasn't consistent by introducing a special range type FirstStepRangeLen when the first index matches the step.

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.02469% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.78%. Comparing base (81a9c1c) to head (1bb316d).

Files with missing lines Patch % Lines
src/firststeprangelen.jl 38.00% 31 Missing ⚠️
src/blockaxis.jl 93.33% 2 Missing ⚠️
src/blocks.jl 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #509      +/-   ##
==========================================
- Coverage   94.39%   92.78%   -1.62%     
==========================================
  Files          19       20       +1     
  Lines        1821     1871      +50     
==========================================
+ Hits         1719     1736      +17     
- Misses        102      135      +33     

☔ 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.

@dlfivefifty dlfivefifty requested a review from mtfishman July 3, 2026 12:35
@dlfivefifty

Copy link
Copy Markdown
Member Author

@mtfishman it will be a while before the coverage is up and all the tests are passing. But perhaps you can have a preliminary look at this?

This is fixing two previous issues:

  1. blockfirsts and blocklengths were allocating. This was fixed via two new lazy types BlockedUnitRangeLengths and BlockedUnitRangeFirsts.
  2. This supports the case where all blocks have the same size via a new range FirstStepRangeLen to represent the block lasts, where the fact that the first index equals the step is hardcoded into the type. This replaces a very questionable temporary hack where I put a random @assert to check that the step and first match.

Any general thoughts about the design would be useful. I'm not convinced with my current naming scheme. And note that BlockedUnitRangeLengths could be called something like InvCumsum or ExtendedDiff as it's basically a lazy representation of diff([0; blocklasts]).

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