Skip to content

src: reserve shared_array_buffers capacity in Message::Deserialize - #65304

Open
agape1225 wants to merge 1 commit into
nodejs:mainfrom
agape1225:src-messaging-reserve-shared-array-buffers
Open

src: reserve shared_array_buffers capacity in Message::Deserialize#65304
agape1225 wants to merge 1 commit into
nodejs:mainfrom
agape1225:src-messaging-reserve-shared-array-buffers

Conversation

@agape1225

Copy link
Copy Markdown
Contributor

shared_array_buffers grows via repeated push_back() while iterating shared_array_buffers_, even though shared_array_buffers_.size() is already known before the loop starts and is an exact count of how many items will be pushed (one per iteration, unconditionally). This reserves capacity upfront to avoid the repeated allocate/copy/ free cycle that happens each time capacity is exceeded, mirroring the existing array_buffers.reserve() in the sibling Message::Serialize().

shared_array_buffers grows via repeated push_back() while iterating
shared_array_buffers_, even though shared_array_buffers_.size() is
already known before the loop starts and is an exact count of how
many items will be pushed (one per iteration, unconditionally).
This reserves capacity upfront to avoid the repeated allocate/copy/
free cycle that happens each time capacity is exceeded, mirroring
the existing array_buffers.reserve() in the sibling
Message::Serialize().

Signed-off-by: agape1225 <49804691+agape1225@users.noreply.github.com>
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Aug 15, 2026
@codecov

codecov Bot commented Aug 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.34%. Comparing base (2929417) to head (ad63add).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65304      +/-   ##
==========================================
- Coverage   90.34%   90.34%   -0.01%     
==========================================
  Files         751      751              
  Lines      250330   250331       +1     
  Branches    47321    47312       -9     
==========================================
- Hits       226171   226150      -21     
- Misses      15557    15568      +11     
- Partials     8602     8613      +11     
Files with missing lines Coverage Δ
src/node_messaging.cc 82.96% <100.00%> (+0.01%) ⬆️

... and 30 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants