Skip to content

Grow StateArena across owner batches#69

Merged
cubenoy22 merged 3 commits into
mainfrom
refactor/arena-math-statearena
Jul 10, 2026
Merged

Grow StateArena across owner batches#69
cubenoy22 merged 3 commits into
mainfrom
refactor/arena-math-statearena

Conversation

@Lihi-AI

@Lihi-AI Lihi-AI commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR handles two related owner-side arena cleanups:

  • move shared arena placement math (AlignOf, NormalizeArenaAlign) into common/app/scene/detail/ArenaMath.hpp
  • let StateArena::reserve() append owner-lifetime blocks across multiple explicit state batches

Why

#56 gives shared arena arithmetic one small scene-detail home instead of making state code depend on Node.hpp.

#55 fixes the owner-level locality hole left after #29: later declareStates() batches can now reserve another arena block instead of falling back to heap merely because an earlier batch seeded the arena.

The growth boundary remains explicit:

  • reserve() is the only operation that appends arena blocks
  • allocate() consumes existing reserved capacity only
  • owner-side immediate declarations reserve one slot before creation
  • unreserved node-local state falls back to heap once existing capacity is exhausted, so detach can reclaim it

Validation

  • cmake --build build/Testing
  • cmake --build build/Testing-ASan
  • ctest --test-dir build/Testing --output-on-failure -R LokaFlowDslTests
  • ctest --test-dir build/Testing-ASan --output-on-failure -R LokaFlowDslTests

Red evidence for the review regression: before e9b6621, the new contract test failed because StateArena::allocate(1024, 4) appended a block after only reserve(32). After the fix, allocation returns 0 until an explicit reserve, and the owner path falls back to heap.

Notes

  • #56: c0ec03e
  • initial #55 implementation: e3b79a3
  • review hardening: e9b6621
  • block and raw-buffer allocation use std::nothrow under the no-exception policy

Closes #55
Closes #56

@cubenoy22 cubenoy22 marked this pull request as ready for review July 7, 2026 06:31
@cubenoy22 cubenoy22 requested a review from Copilot July 7, 2026 06:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 centralizes shared arena placement/alignment math into a small scene-detail header and updates StateArena so owner-side state allocation can grow across multiple batches (instead of being effectively one-shot per owner), with a new contract test covering the multi-batch behavior.

Changes:

  • Added common/app/scene/detail/ArenaMath.hpp and moved AlignOf / NormalizeArenaAlign usage to loka::app::scene::detail::*.
  • Refactored StateArena to use chained blocks and allow allocate() to append new blocks when the current one is exhausted.
  • Added a focused boundary/arena test that pins multi-batch owner locality and immediate state creation behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/BoundaryArenaTests.cpp Adds a test owner + new contract test to verify StateArena grows across multiple owner batches and supports immediate state creation.
common/app/scene/state/StateBatchBase.hpp Removes dependency on Node.hpp by using the new arena math header and detail:: alignment helpers.
common/app/scene/node/Conditional.cpp Updates node alignment query to use detail::AlignOf.
common/app/scene/Node.hpp Removes embedded arena math and includes detail/ArenaMath.hpp; updates node alignment to detail::AlignOf.
common/app/scene/detail/ArenaMath.hpp New shared header providing AlignOf and NormalizeArenaAlign for arena sizing/allocation.
common/app/scene/composition/NodeComposition.cpp Switches to detail/ArenaMath.hpp and detail::NormalizeArenaAlign for node arena sizing.
common/app/scene/boundary/detail/BoundaryArena.hpp Implements growable StateArena via chained blocks; updates arena alignment normalization calls.
common/app/scene/boundary/Boundary.hpp Always forwards reserve hints to StateArena (no longer gated on first-capacity).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread common/app/scene/boundary/detail/BoundaryArena.hpp
Comment thread common/app/scene/boundary/detail/BoundaryArena.hpp
Comment thread common/app/scene/state/StateBatchBase.hpp

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e3b79a347d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread common/app/scene/boundary/detail/BoundaryArena.hpp Outdated
@cubenoy22 cubenoy22 merged commit 870649d into main Jul 10, 2026
@cubenoy22 cubenoy22 deleted the refactor/arena-math-statearena branch July 10, 2026 09:58
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.

Move arena placement math (NormalizeArenaAlign, AlignOf) to a small detail header Grow StateArena across multiple state batches owned by one Boundary

3 participants