-
Notifications
You must be signed in to change notification settings - Fork 0
Add Fixed Slot Infrastructure #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Implement centralized iteration over fixed slot TypedPools using @generated function with compile-time unrolling. Changes: - Add FIXED_SLOT_FIELDS constant for explicit slot enumeration - Add foreach_fixed_slot() with @_inline_meta for guaranteed inlining - Refactor checkpoint!, rewind!, empty! to use foreach_fixed_slot - Add comprehensive test suite (52 tests) for synchronization and zero-allocation verification Design decision: Use explicit FIXED_SLOT_FIELDS tuple instead of fieldtypes() filtering to prevent accidental inclusion of future internal TypedPool fields.
- Add ComplexF32 as new fixed slot type alongside ComplexF64 - Refactor _check_pointer_overlap to use foreach_fixed_slot - Refactor pool_stats to use foreach_fixed_slot with dynamic type extraction - Refactor Base.show to use foreach_fixed_slot with Ref counters - Add ComplexF32 tests for symmetry with ComplexF64 tests This ensures FIXED_SLOT_FIELDS is the single source of truth - no more hardcoded slot lists to maintain separately.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7 +/- ##
==========================================
+ Coverage 94.60% 96.46% +1.85%
==========================================
Files 7 7
Lines 575 565 -10
==========================================
+ Hits 544 545 +1
+ Misses 31 20 -11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds infrastructure to improve maintainability and performance when working with fixed slot types in the AdaptiveArrayPool. The main contribution is the introduction of FIXED_SLOT_FIELDS as a single source of truth and foreach_fixed_slot for type-stable, zero-allocation iteration. Additionally, ComplexF32 is added as a new fixed slot type.
Key Changes:
- New
FIXED_SLOT_FIELDSconstant tuple centralizes the list of fixed slot field names - New
foreach_fixed_slot@generated function enables compile-time unrolled iteration over fixed slots ComplexF32added as the 7th fixed slot type alongside existing Float64, Float32, Int64, Int32, ComplexF64, and Bool
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/types.jl | Added FIXED_SLOT_FIELDS constant, foreach_fixed_slot @generated function, ComplexF32 fixed slot type definition and dispatch |
| src/state.jl | Refactored checkpoint!, rewind!, and empty! to use foreach_fixed_slot instead of hardcoded iteration |
| src/utils.jl | Refactored _check_pointer_overlap, pool_stats, and Base.show to use foreach_fixed_slot for consistent fixed slot iteration |
| src/acquire.jl | Removed internal _acquire_impl! and _unsafe_acquire_impl! fallback methods for ::Nothing (no longer needed as macros handle pool=nothing separately) |
| test/test_fixed_slots.jl | New comprehensive test file verifying FIXED_SLOT_FIELDS synchronization, foreach_fixed_slot behavior, type stability, and zero allocation |
| test/test_basic.jl | Added test coverage for ComplexF32 fixed slot type |
| test/test_state.jl | Updated checkpoint!/rewind! tests to include ComplexF32 |
| test/test_utils.jl | Updated _validate_pool_return tests to include ComplexF32 |
| test/test_aliases.jl | Added runtime coverage tests for similar-style _impl! methods called via macro transformation |
| test/runtests.jl | Included new test_fixed_slots.jl in test suite |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
FIXED_SLOT_FIELDSconstant tuple as single source of truth for fixed slot field namesforeach_fixed_slot@generated function for type-stable, zero-allocation iterationComplexF32as new fixed slot typeutils.jlto useforeach_fixed_slotWhat's Changed
New:
FIXED_SLOT_FIELDSSingle source of truth for fixed slot field names. Used by
foreach_fixed_slotand tests.New:
foreach_fixed_slotZero-allocation iteration via
@generatedfunction that reads fromFIXED_SLOT_FIELDS.Refactored (utils.jl only)
pool_stats,Base.show,_check_pointer_overlap: hardcoded tuple →foreach_fixed_slotNot Changed
Adding a new fixed slot still requires updating 4 places:
FIXED_SLOT_FIELDSAdaptiveArrayPoolstructAdaptiveArrayPool()constructorget_typed_pool!dispatchBenefits
getfield(pool, field::Symbol)→ compile-time unrollingFIXED_SLOT_FIELDSTest Coverage
test_fixed_slots.jl: auto-verifiesFIXED_SLOT_FIELDSand struct synchronization