-
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
src: remove BINARY encoding #5504
Conversation
It was fun, now it is gone.
cc @nodejs/ctc @nodejs/collaborators @nodejs/crypto |
Could you explain what benefit this is to us? I don't really understand. |
Of course, As it is right now, it does not provide much use IMO, and there are lots of code to handle it. Therefore I propose removing it. |
-100. The |
@mscdex example? |
What if I will change defaults for |
@indutny Regexps was one such example. Anything from |
@mscdex why |
@indutny I think the reason that the default encoding is
I'm not sure what you mean here. Converting binary to utf8 is not safe. |
+1 it was meant to be removed long ago. @mscdex why would you use regexp for non-textual data? |
@mscdex it is not safe to pass @mscdex I would really appreciate if you could share a link with me, demonstrating a use case in some project. From what I heard, it does not look like |
@seishun Because it's useful if you need something more than a simple |
@indutny My point is that if you change the default encoding to utf8, strings containing binary bytes can get misinterpreted:
|
Well, same thing with > new Buffer('привет', 'binary').toString()
'?@825B' |
@indutny I don't see that as the same thing. Once you have imported the binary string with the 'binary' encoding there is no need to do |
@mscdex what is "import the string safely" in your definition? |
Is there any performance impact when using |
@indutny "safely" meaning the data/content is not modified |
Debug mode slows execution speed. There is work afoot to enable Debug mode runs on the continuous integration infrastructure for the project. Some tests are timing out, such as test-net-nodejsGH-5504.js. This change doubles the timeout returned from `common.platformTimeout()` when running in Debug mode. It also removes an unused variable from the aforementioned test-net-nodejsGH-5504.js. PR-URL: nodejs#4431 Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Examples when Binary is useful: var obj = {};
function wasExecuted(buf) {
return buf.toString('binary') in obj;
//Here we could use hex but it works slower and requires more memory
} function addNumberToString(s, num) {
var isBuf = Buffer.isBuffer(s) && (s = s.toString('binary'), true);
//Here we can work with s like usual string. We don't need write individual
//code for Buffer case. Of course we shouldn't add to string big char codes.
s = s + num;
return isBuf ? new Buffer(s, 'binary') : s;
} I guess I can not use utf8 in these examples because not all bytes sequences can be safely converted to utf8, am I right? |
@vitaliylag The majority of utf8 byte sequences can't be converted. A useful usage I've used in the past is when I want to hold many open file contents that are relatively large in size (>= 1MB). Done this while parsing data sets. If the file text can be assumed as ascii or latin1 then the string can be referenced out side of the heap. Example script: const buf = Buffer.alloc(1024 * 1024, 'a');
const arr = [];
for (var i = 0; i < 1e3; i++) {
arr.push(buf.toString('binary'));
//arr.push(buf.toString('utf8'));
}
process._rawDebug(require('v8').getHeapStatistics().used_heap_size / 0x100000); Using |
Avoid transient DNS issues in test sequential/test-net-GH-5504 by using the IP address instead of the 'localhost' host name. Fixes: nodejs#6611 PR-URL: nodejs#7524 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Avoid transient DNS issues in test sequential/test-net-GH-5504 by using the IP address instead of the 'localhost' host name. Fixes: #6611 PR-URL: #7524 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Avoid transient DNS issues in test sequential/test-net-GH-5504 by using the IP address instead of the 'localhost' host name. Fixes: #6611 PR-URL: #7524 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Avoid transient DNS issues in test sequential/test-net-GH-5504 by using the IP address instead of the 'localhost' host name. Fixes: #6611 PR-URL: #7524 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Avoid transient DNS issues in test sequential/test-net-GH-5504 by using the IP address instead of the 'localhost' host name. Fixes: #6611 PR-URL: #7524 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Avoid transient DNS issues in test sequential/test-net-GH-5504 by using the IP address instead of the 'localhost' host name. Fixes: #6611 PR-URL: #7524 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Avoid transient DNS issues in test sequential/test-net-GH-5504 by using the IP address instead of the 'localhost' host name. Fixes: #6611 PR-URL: #7524 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
test-net-nodejsGH-5504 failed on smartos14-64 in CI. The internal test timeout expired. It is currently 2 seconds. That appears to be somewhat arbitrary. It may be possible to rewrite the test without the timer. As an immediate workaround, increase the timeout to 5 seconds.
The test is failing on `SmartOS` quite often. Removing the timeout seems to fix it. Fixes: nodejs#8930 PR-URL: nodejs#9461 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
* Improve comments describing test. * Remove unnecessary `common.noop` * Remove confusing scoping of `c` identifier
* Improve comments describing test. * Remove unnecessary `common.noop` * Remove confusing scoping of `c` identifier PR-URL: nodejs#13025 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Pull Request check-list
Please make sure to review and check all of these items:
make -j8 test
(UNIX) orvcbuild test nosign
(Windows) pass withthis change (including linting)?
test (or a benchmark) included?
existing APIs, or introduces new ones)?
NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.
Affected core subsystem(s)
Please provide affected core subsystem(s) (like buffer, cluster, crypto, etc)
Description of change
It was fun,
now it is gone.
I decided to follow @chrisdickinson footsteps and submit provocative PR 😉 Hopefully this will help to spin of a useful discussion!