Skip to content

[V4] Slab stack No.2#94

Merged
ConorWilliams merged 18 commits intomodulesfrom
v4-slab-2
Apr 22, 2026
Merged

[V4] Slab stack No.2#94
ConorWilliams merged 18 commits intomodulesfrom
v4-slab-2

Conversation

@ConorWilliams
Copy link
Copy Markdown
Owner

@ConorWilliams ConorWilliams commented Apr 8, 2026

Summary by CodeRabbit

  • New Features

    • Introduced slab_stack, a fixed-size, single-slab user-space stack implementation for memory allocation.
    • Extended benchmarks to include slab_stack variants.
  • Bug Fixes

    • Fixed const-correctness in geometric_stack method signature.
    • Corrected typo in comment.
  • Tests

    • Added comprehensive test coverage for slab_stack across multiple scenarios, including allocation limits and checkpoint/acquire/release cycles.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 8, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4121da73-3136-4d8b-b10a-cd7590e0ca85

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch v4-slab-2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ConorWilliams ConorWilliams force-pushed the v4-uts-port branch 2 times, most recently from 2010d15 to 948912f Compare April 8, 2026 19:39
@ConorWilliams ConorWilliams force-pushed the v4-slab-2 branch 2 times, most recently from ffc365c to 03c498b Compare April 9, 2026 21:42
@ConorWilliams ConorWilliams changed the base branch from v4-uts-port to modules April 9, 2026 21:42
@ConorWilliams ConorWilliams force-pushed the v4-slab-2 branch 3 times, most recently from d1adcf0 to e91cd5d Compare April 20, 2026 21:20
@ConorWilliams ConorWilliams marked this pull request as ready for review April 20, 2026 21:22
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/batteries/slab_stack.cxx`:
- Around line 109-114: The push() routine currently does pointer arithmetic
diff_type free_bytes = node_size * (m_hi - m_sp) which is UB if init_slab failed
in release() leaving m_ctrl/m_lo/m_sp/m_hi == nullptr; modify push() to first
check that m_hi and m_sp are non-null (e.g., if (m_hi == nullptr || m_sp ==
nullptr) throw std::bad_alloc{} or handle as out-of-space) before performing
m_hi - m_sp, and apply the same null-safety check in the analogous location
around lines 158-163; also update the comment in release() to note that pointers
are cleared and that callers must handle null pointer state so subsequent
pointer arithmetic is guarded.

In `@test/src/stack.cpp`:
- Around line 129-137: Wrap tests that depend on exceptions with conditional
compilation and avoid catching std::bad_alloc for stacks that allocate
dynamically: enclose the entire "slab_stack - throws when full" test in `#if`
LF_COMPILER_EXCEPTIONS ... `#endif`, and in the TEMPLATE_TEST_CASEs that iterate
over geometric_stack, adaptor_stack and slab_stack, remove or guard the
try/catch(std::bad_alloc) blocks with `#if` LF_COMPILER_EXCEPTIONS so only
slab_stack is allowed to trigger and catch bad_alloc; alternatively use
type-specific branches (e.g., if constexpr or trait for fixed_capacity_stack) to
only perform exception-based early-exit logic for slab_stack and use standard
allocation failure checks for geometric_stack/adaptor_stack.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1d47dbc6-0c30-4623-a7d3-0840622eb4b7

📥 Commits

Reviewing files that changed from the base of the PR and between 387d763 and d493533.

📒 Files selected for processing (6)
  • CMakeLists.txt
  • benchmark/src/libfork_benchmark/fib/libfork.cpp
  • src/batteries/batteries.cxx
  • src/batteries/geometric_stack.cxx
  • src/batteries/slab_stack.cxx
  • test/src/stack.cpp

Comment thread src/batteries/slab_stack.cxx
Comment thread test/src/stack.cpp
@ConorWilliams ConorWilliams merged commit a8d94b1 into modules Apr 22, 2026
7 of 10 checks passed
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