Skip to content

fix: Fix Session allocation problem#649

Closed
zhanglei1949 wants to merge 2 commits into
alibaba:mainfrom
zhanglei1949:codex/fix-sessionpool-aligned-allocation
Closed

fix: Fix Session allocation problem#649
zhanglei1949 wants to merge 2 commits into
alibaba:mainfrom
zhanglei1949:codex/fix-sessionpool-aligned-allocation

Conversation

@zhanglei1949

Copy link
Copy Markdown
Member

Fix #647

@zhanglei1949 zhanglei1949 requested review from Copilot and liulx20 June 30, 2026 00:20

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

Note

Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.

This PR addresses #647 by ensuring session-local contexts are allocated with a page-sized alignment and adds coverage to verify the alignment behavior.

Changes:

  • Introduces a 4096-byte alignment for SessionLocalContext and allocates the pool storage using aligned operator new[]/delete[].
  • Adds a unit test to assert session storage is aligned to the expected boundary.

Reviewed changes

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

File Description
tests/unittest/test_db_svc.cc Adds a unit test validating session allocation alignment.
include/neug/server/session_pool.h Implements page-aligned SessionLocalContext and switches allocation/deallocation to aligned operator new[]/delete[].

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

Comment on lines +33 to +35
inline constexpr std::size_t kSessionContextAlignment = 4096;

struct alignas(kSessionContextAlignment) SessionLocalContext {
Comment on lines +224 to +225
static_assert(alignof(SessionLocalContext) == kSessionContextAlignment);
static_assert(sizeof(SessionLocalContext) % kSessionContextAlignment == 0);
Comment on lines +80 to +81
const auto session_address = reinterpret_cast<std::uintptr_t>(guard.get());
EXPECT_EQ(session_address % neug::kSessionContextAlignment, 0U);
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.

SessionPool aligned_alloc may return null when allocation size is not alignment-multiple

2 participants