fix: Fix Session allocation problem#649
Closed
zhanglei1949 wants to merge 2 commits into
Closed
Conversation
Contributor
There was a problem hiding this comment.
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
SessionLocalContextand allocates the pool storage using alignedoperator 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #647