-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
buffer: remove MAX_SAFE_INTEGER check on length #14131
Conversation
MAX_SAFE_INTEGER is millions of times larger than the largest buffer allowed in Node.js. There is no need to squash the length down to MAX_SAFE_INTEGER. Removing that check results in a small but statistically significant increase for Buffer.from() operating on ArrayBuffers in some situations.
improvement confidence p.value
buffers/buffer-from.js n=2048 len=10 source="arraybuffer-middle" 1.54 % ** 0.001666215
buffers/buffer-from.js n=2048 len=2048 source="arraybuffer-middle" 1.76 % ** 0.003719416 |
If you do somehow manage to get
Before, if you manage to go here, say with
This seems more correct to me. You're getting the actual length that is problematic rather than some other length that you didn't specify. |
Is this technically semver-major due to the possible error change for large values? |
No, IMO. |
Depends on resolution of #13937 |
A ~1.5% of the time was used for that |
I agree. If the wording changed, then yes. But since it's just correcting the (IMO) wrong value repeated back to the user, I would say no.
I don't think so because that's about changes after we move to the new internal error system. This one is not part of the new internal error system. |
Landed in e6e6b07 |
MAX_SAFE_INTEGER is millions of times larger than the largest buffer allowed in Node.js. There is no need to squash the length down to MAX_SAFE_INTEGER. Removing that check results in a small but statistically significant increase for Buffer.from() operating on ArrayBuffers in some situations. PR-URL: #14131 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]>
MAX_SAFE_INTEGER is millions of times larger than the largest buffer allowed in Node.js. There is no need to squash the length down to MAX_SAFE_INTEGER. Removing that check results in a small but statistically significant increase for Buffer.from() operating on ArrayBuffers in some situations. PR-URL: #14131 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]>
MAX_SAFE_INTEGER is millions of times larger than the largest buffer allowed in Node.js. There is no need to squash the length down to MAX_SAFE_INTEGER. Removing that check results in a small but statistically significant increase for Buffer.from() operating on ArrayBuffers in some situations. PR-URL: #14131 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]>
MAX_SAFE_INTEGER is millions of times larger than the largest buffer allowed in Node.js. There is no need to squash the length down to MAX_SAFE_INTEGER. Removing that check results in a small but statistically significant increase for Buffer.from() operating on ArrayBuffers in some situations. PR-URL: #14131 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]>
Should this be backported to |
@MylesBorins Did you mean to label this either |
(Changed to backport requested..) |
@MylesBorins If #12361 lands in v6.x-staging, then this should land and will land cleanly. If #12361 does not land in v6.x-staging, then neither should this. #12361 is currently marked for |
MAX_SAFE_INTEGER is millions of times larger than the largest buffer
allowed in Node.js. There is no need to squash the length down to
MAX_SAFE_INTEGER. Removing that check results in a small but
statistically significant increase for Buffer.from() operating on
ArrayBuffers in some situations.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
buffer