Skip to content

Refactor occupancy_t type to reduce memory allocations#296

Open
rouson wants to merge 8 commits into
mainfrom
refactor-occupancy_t
Open

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

Conversation

@rouson

@rouson rouson 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.

@rouson rouson changed the title Refactor demo's occupancy_t to reduce the number of memory allocations Refactor occupancy_t type to reduce memory allocations Jul 18, 2026
rouson added 8 commits July 18, 2026 01:22
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
rouson force-pushed the refactor-occupancy_t branch from efe7de1 to 22097e3 Compare July 18, 2026 08:22
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