Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix severe node performance issue due to buffer allocation bug, fix undefined behavior which breaks node > 18.7.0 #82

Open
wants to merge 3 commits into
base: latest
Choose a base branch
from

Conversation

afreer
Copy link

@afreer afreer commented Sep 19, 2023

Fixes two important issues:

  1. Fixes a severe node performance issue due to buffer allocation bug, this fix comes from @doggkruse in Change to using std::min() when allocating Buffers #73.
  2. Fixes undefined behavior which breaks node > 18.7.0. I believe I tracked down the issue to the "GetBackingStore" updates referenced in the 18.8.0 release notes. Release notes here: https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V18.md. The issue was addressed in several PRs created to address this issue: buffer: ~2x slowdown in master compared to v12.x nodejs/node#32226.

Please let me know if any further work is needed, I would be happy to help, this would be nice to get merged in and released. Thank you!

doggkruse and others added 3 commits September 19, 2023 11:38
…his will result in Buffers being allocated to the size requested up to kMaxLength (0x3fffffff) instead of the current behavior of always allocating kMaxLength. Since these buffers are allocated in the node external memory (limited to 64M) the old behavior would very quickly cause massive GC pressure as the GC is triggered on each new Buffer allocation once the node external memory limit is reached. It appears the old behavior was not intentional and should have always been std::min(). This should fix node-ffi-napi#72
…an the current request. This is likely what drove the problematic max size allocation
btsimonh added a commit to btsimonh/ref-napi that referenced this pull request Oct 28, 2024
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.

2 participants