GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [v22.x backport] src: add percentage support to --max-old-space-size by Asaf-Federman · Pull Request #59631 · nodejs/node

Conversation

@Asaf-Federman

@Asaf-Federman Asaf-Federman commented Aug 26, 2025

Copy link
Copy Markdown
Contributor

These commits add support for specifying --max-old-space-size as a percentage of system memory, in addition to the existing MB format.

PR-URL: #59082
PR-URL: #59460

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ikhtearalamshawonmollah54321 reacted with thumbs up emoji winterrdog and ikhtearalamshawonmollah54321 reacted with rocket emoji
All reactions
  • 👍 1 reaction
  • 🚀 2 reactions
@nodejs-github-bot

nodejs-github-bot commented Aug 26, 2025

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/config
  • @nodejs/startup
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. v22.x Issues that can be reproduced on v22.x or PRs targeting the v22.x-staging branch. labels Aug 26, 2025
@Asaf-Federman Asaf-Federman mentioned this pull request Aug 26, 2025
src: add percentage support to --max-old-space-size #59082
Merged
@Asaf-Federman
Asaf-Federman force-pushed the backport-max-old-space-size-percentage-to-v22.x branch from 1520d5e to dac7895 Compare September 4, 2025 09:59
@Asaf-Federman

Asaf-Federman commented Sep 4, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

cc @aduh95

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Sep 17, 2025

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/69270/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@richardlau

This comment was marked as resolved.

Sign in to view
@Asaf-Federman

Asaf-Federman commented Sep 18, 2025 •
edited by aduh95
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

While some of the test failures are flakes, the test added in this backport PR is failing on 32-bit Linux on ARM and 32-bit Windows. e.g.

Since this flag's behavior depends on V8's complex and platform-specific heap sizing logic, creating a test that perfectly models these heuristics is likely to be brittle. Therefore, I think the most pragmatic solution is to skip these assertions.

What are your thoughts?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@richardlau

richardlau commented Sep 22, 2025

Copy link
Copy Markdown
Member

Since this flag's behavior depends on V8's complex and platform-specific heap sizing logic, creating a test that perfectly models these heuristics is likely to be brittle. Therefore, I think the most pragmatic solution is to skip these assertions.

What are your thoughts?

My concern is that we don't run tests on 32-bit platforms on main/Node.js 24.x, so this is the first time we've tried this feature on those platforms. And while allowances might be made for the comparison in these tests to not be exactly half, the tests would seem to indicate that a 50% value is leading in some cases to a larger heap being allocated than 100% in some cases which indicates the opposite of the desired effect?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Asaf-Federman

Asaf-Federman commented Sep 23, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Hi @richardlau,

Following up on the discussion, I've run some tests on the behavior of --max-old-space-size on a 32-bit ARM (armv7l) system. The results show some significant inconsistencies that likely explain why --max-old-space-size-percentage would also be unreliable on this architecture.

Test Environment

  • Node.js Version: v22.19.0
  • Architecture: armv7l (32-bit ARM)
  • Script Used:
    // heap_check.js
    const v8 = require('v8');
    
    // Get heap statistics from the V8 engine.
    const stats = v8.getHeapStatistics();
    
    // A simple function to format bytes into megabytes.
    const toMB = (bytes) => (bytes / 1024 / 1024).toFixed(2);
    
    console.log('V8 Heap Statistics:');
    console.log(`- Used Heap Size: ${toMB(stats.used_heap_size)} MB`);
    console.log(`- Total Heap Available: ${toMB(stats.total_available_size)} MB`);
    console.log(`- Heap Size Limit: ${toMB(stats.heap_size_limit)} MB`);
    
    // The --max-old-space-size flag primarily affects this limit.
    // The total limit is slightly higher to account for other memory spaces.

Results

Here is a summary of the requested heap size versus the actual limit reported by V8.

  root@e0332c781f29:/# node --version
  v22.19.0
  root@e0332c781f29:/# uname -m
  armv7l
  root@e0332c781f29:/# node --max-old-space-size=2000 heap_check.js
  V8 Heap Statistics:
  - Used Heap Size: 2.00 MB
  - Total Heap Available: 2009.87 MB
  - Heap Size Limit: 2012.00 MB
  root@e0332c781f29:/# node --max-old-space-size=5000 heap_check.js
  V8 Heap Statistics:
  - Used Heap Size: 1.99 MB
  - Total Heap Available: 913.87 MB
  - Heap Size Limit: 916.00 MB
  root@e0332c781f29:/# node --max-old-space-size=13000 heap_check.js
  V8 Heap Statistics:
  - Used Heap Size: 1.99 MB
  - Total Heap Available: 721.87 MB
  - Heap Size Limit: 724.00 MB
  root@e0332c781f29:/# node --max-old-space-size=14000 heap_check.js
  V8 Heap Statistics:
  - Used Heap Size: 1.99 MB
  - Total Heap Available: 1721.87 MB
  - Heap Size Limit: 1724.00 MB

Analysis & Conclusion

The data shows that V8's memory allocation on 32-bit ARM is not just capped, but behaves erratically when given large values. The most telling result is that requesting 13000 MB results in a smaller heap limit than requesting 5000 MB.

This underlying instability confirms that the heap size is not handled predictably on this architecture. It strongly suggests that the --max-old-space-size-percentage flag would be subject to the same unreliable behavior, as it's ultimately bound by this same allocation logic.

I strongly believe we should skip those tests for 32bit architecture.
Maybe it's worth adding the lack of support for 32bit architecture to the cli documentation as well.

WDYT?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

richardlau
richardlau approved these changes Sep 24, 2025
View reviewed changes
@richardlau richardlau added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Sep 24, 2025
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Sep 24, 2025
@nodejs-github-bot

nodejs-github-bot commented Sep 24, 2025

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/69359/

ikhtearalamshawonmollah54321 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Asaf-Federman

Asaf-Federman commented Sep 26, 2025

Copy link
Copy Markdown
Contributor Author

The tests seem to fail due to flakiness

ikhtearalamshawonmollah54321 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Oct 1, 2025

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/69491/

ikhtearalamshawonmollah54321 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Asaf-Federman

Asaf-Federman commented Oct 5, 2025

Copy link
Copy Markdown
Contributor Author

Hi @richardlau,
the CI is 🆗, can we please move this effort forward?

Thanks in advance :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aduh95

aduh95 commented Oct 7, 2025

Copy link
Copy Markdown
Contributor

I think 8733b91 should land on main first before we can proceed

ikhtearalamshawonmollah54321 and Asaf-Federman reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Asaf-Federman
Asaf-Federman force-pushed the backport-max-old-space-size-percentage-to-v22.x branch 2 times, most recently from 41f02f6 to ffdc838 Compare October 9, 2025 17:03
@Asaf-Federman

Asaf-Federman commented Oct 10, 2025

Copy link
Copy Markdown
Contributor Author

Hi @richardlau @aduh95,
I've updated the PR with ffdc838 (after it was merged to main)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aduh95
aduh95 force-pushed the v22.x-staging branch from 1f681ad to ef005d0 Compare October 11, 2025 18:50
Asaf-Federman and others added 3 commits October 12, 2025 01:43
@Asaf-Federman
src: add percentage support to --max-old-space-size
b932ba7
This commit adds support for specifying --max-old-space-size as a
percentage of system memory, in addition to the existing MB format.
A new HandleMaxOldSpaceSizePercentage method parses percentage values,
validates that they are within the 0-100% range, and provides clear
error messages for invalid input. The heap size is now calculated
based on available system memory when a percentage is used.

Test coverage has been added for both valid and invalid cases.
Documentation and the JSON schema for CLI options have been updated
with examples for both formats.

Refs: nodejs#57447
PR-URL: nodejs#59082
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: theanarkh <[email protected]>
Reviewed-By: Daeyeon Jeong <[email protected]>
@Asaf-Federman
src: assert memory calc for max-old-space-size-percentage
cf0bc76
Add validation to ensure that --max-old-space-size-percentage cannot
be used when available memory cannot be calculated, preventing
undefined behavior when memory detection fails.

Also enhance test-process-constrained-memory.js to support testing
in constrained environments where memory calculation may fail.

PR-URL: nodejs#59460
Reviewed-By: theanarkh <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
@Asaf-Federman
test,doc: skip --max-old-space-size-percentage on 32-bit platforms
fa96235
PR-URL: nodejs#60144
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Ulises Gascón <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
@Asaf-Federman
Asaf-Federman force-pushed the backport-max-old-space-size-percentage-to-v22.x branch from ffdc838 to fa96235 Compare October 11, 2025 22:43
richardlau
richardlau approved these changes Oct 13, 2025
View reviewed changes
@richardlau richardlau added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 13, 2025
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 13, 2025
@nodejs-github-bot

nodejs-github-bot commented Oct 13, 2025

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/69709/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Asaf-Federman

Asaf-Federman commented Oct 15, 2025

Copy link
Copy Markdown
Contributor Author

Hi @richardlau,
how can we move this PR toward landing?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@richardlau

richardlau commented Oct 15, 2025

Copy link
Copy Markdown
Member

@aduh95 Do you think we can pull this into #60230 (the last release before Node.js 22 enters maintenance)?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

aduh95
aduh95 approved these changes Oct 17, 2025
View reviewed changes
aduh95 pushed a commit that referenced this pull request Oct 17, 2025
@Asaf-Federman @aduh95
src: add percentage support to --max-old-space-size
686ac49
This commit adds support for specifying --max-old-space-size as a
percentage of system memory, in addition to the existing MB format.
A new HandleMaxOldSpaceSizePercentage method parses percentage values,
validates that they are within the 0-100% range, and provides clear
error messages for invalid input. The heap size is now calculated
based on available system memory when a percentage is used.

Test coverage has been added for both valid and invalid cases.
Documentation and the JSON schema for CLI options have been updated
with examples for both formats.

Refs: #57447
PR-URL: #59082
Backport-PR-URL: #59631
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: theanarkh <[email protected]>
Reviewed-By: Daeyeon Jeong <[email protected]>
aduh95 pushed a commit that referenced this pull request Oct 17, 2025
@Asaf-Federman @aduh95
src: assert memory calc for max-old-space-size-percentage
42c5544
Add validation to ensure that --max-old-space-size-percentage cannot
be used when available memory cannot be calculated, preventing
undefined behavior when memory detection fails.

Also enhance test-process-constrained-memory.js to support testing
in constrained environments where memory calculation may fail.

PR-URL: #59460
Backport-PR-URL: #59631
Reviewed-By: theanarkh <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
aduh95 pushed a commit that referenced this pull request Oct 17, 2025
@Asaf-Federman @aduh95
test,doc: skip --max-old-space-size-percentage on 32-bit platforms
660d573
PR-URL: #60144
Backport-PR-URL: #59631
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Ulises Gascón <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
@aduh95

aduh95 commented Oct 17, 2025

Copy link
Copy Markdown
Contributor

Landed on 7067d79...660d573

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aduh95 aduh95 closed this Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@richardlau richardlau richardlau approved these changes
@aduh95 aduh95 aduh95 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. v22.x Issues that can be reproduced on v22.x or PRs targeting the v22.x-staging branch.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@Asaf-Federman @nodejs-github-bot @richardlau @aduh95
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.