Use native Buffer whenever available #1032
Open
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.
Context and fix:
Use the native Buffer when available. This is done to get better performance and system stability when operating on large buffers
For example, when converting a large buffer to a string, the native Buffer is much faster than the isomorphic buffer. It supports toString() operation on buffers of size up to 512MB, while the isomorphic buffer errors out after 100MB.
Additional Changes
Performance benchmarking results for
toString()
(Node):NOTE : On develop + Node v20 and below, the process crashes for size greater than ~120MB. For v22 we get "invalid array length" error (maked by
undefined
in the results below)Script for benchmarking
Node v16
develop
This branch
Node v18
develop
This branch
Node v20
develop
This branch
Node v22
develop
This branch