Skip to content

Refactor occupancy_t type to reduce memory allocations - #296

Merged
rouson merged 8 commits into
mainfrom
refactor-occupancy_t
Jul 21, 2026
Merged

Refactor occupancy_t type to reduce memory allocations#296
rouson merged 8 commits into
mainfrom
refactor-occupancy_t

Conversation

@rouson

@rousonrouson commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

This PR

  1. Adds a unit test for the demo directory's occupancey_t type in order to support refactoring it
  2. Refactors occupancy_t type to store the number of occupied bins separately from the occupied-bins array so the array can be longer than the number of occupied bins when necessary
  3. Uses the resulting flexibility to reduce the number of memory allocations over the course of runs.

Now the occupied-bin array doubles in size whenever the addition of a new bin requires a longer list. This implies that growing the list to size N requires only $$log_2(N)$$ memory allocations instead of N allocations.

@rousonrouson changed the title Refactor demo's occupancy_t to reduce the number of memory allocationsRefactor occupancy_t type to reduce memory allocationsJul 18, 2026
@rouson
rousonforce-pushed the refactor-occupancy_t branch from efe7de1 to 22097e3CompareJuly 18, 2026 08:22
rouson added 8 commits July 21, 2026 13:46
This commit replaces the occupancy_t type's logical array
components that were dimensioned to cover the tensor-component
space for purposes of tracking each bin's occupation. The
replacement component stores the component-space location of
only the occupied bins.
This commit stores the number of occupied bins separately from the
occupied bins list so that the list can be longer when necessary
in order to reduce the number of memory allocations over the course
of runs.
This commit doubles the occupied-bin list in size when adding
a bin requires a longer list. Now growing the list to size N,
requires only log_2(N) memory allocations instead of N allocations.
@rouson
rousonforce-pushed the refactor-occupancy_t branch from 22097e3 to 2725b43CompareJuly 21, 2026 17:46
@rouson
rouson merged commit 03aacbb into mainJul 21, 2026
4 checks passed
@rouson
rouson deleted the refactor-occupancy_t branch July 21, 2026 20:24
Sign up for freeto 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

@rouson