Uh oh!
There was an error while loading. Please reload this page.
string_decoder: rewrite implementation - #6777
Conversation
There was a problem hiding this comment.
I'm thinking it would make sense to move this into an internal util
There was a problem hiding this comment.
Perhaps. I was working on some Buffer changes that might end up doing something similar.
There was a problem hiding this comment.
fwiw, I had been experimenting with something similar in the speculative icu module work. See https://github.com/jasnell/node/blob/icu-module/lib/icu.js#L113-L134.
jasnell
commented
May 15, 2016
Overall there's nothing that stands out as being a concern here. I would note that the documentation for string_decoder leaves much to be desired but that can be fixed up later. If CI is green then LGTM |
mscdex
commented
May 15, 2016
There was a problem hiding this comment.
This should default to utf8 when encoding is empty/undefined/generally false-y, no?
addaleax
commented
May 16, 2016
CI is green, and LGTM if the fallback to |
e034539 to
21cc740Comparemscdex
commented
May 16, 2016
CI after a few nits were addressed: https://ci.nodejs.org/job/node-test-pull-request/2652/ |
21cc740 to
efd0a38CompareI had to change the UTF-8 implementation due to being unable to distinguish between explicit and implicit replacement characters. The new UTF-8 implementation now does incomplete character checking similar to the original implementation. UTF-8 performance numbers are still the same however. |
addaleax
commented
May 16, 2016
CI with the most recent changes: https://ci.nodejs.org/job/node-test-commit/3352/ |
mscdex
commented
May 18, 2016
@jasnell Does this still LGTY (after the changes I made to the UTF-8 implementation)? |
jasnell
commented
May 18, 2016
Yes. I'd like to see if we can make further improvements and optimizations to this but this LGTM |
mscdex
commented
May 18, 2016
@jasnell I'm not sure much more is possible for UTF-8 on the js-side of things. AFAIK the only way now to optimize UTF-8 further would be to try to skip v8's UTF-8 decoder and use a custom C/C++ UTF-8 to UTF-16 decoder and pass the resulting output to v8? I'm assuming v8 doesn't do any additional processing on two-byte strings (created via |
I'm being extra cautious and marking this as not for v4.x. If it's one thing I've learned, it's that node's tests aren't always up to snuff and may not (always) be good enough for checking rewrites like this. Let's let it stew in current branches first. |
ICU includes a number of highly optimized UTF8/UTF16 utilities that could potentially be leveraged. In fact, we might be able to drop down to a full native implementation of string_decoder that is based entirely on ICU's utilities. |
bnoordhuis
commented
May 18, 2016
LGTM |
This commit provides a rewrite of StringDecoder that both improves performance (for non-single-byte encodings) and understandability. Additionally, StringDecoder instantiation performance has increased considerably due to inlinability and more efficient encoding name checking. PR-URL: nodejs#6777 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
efd0a38 to
d23b7d2Comparemscdex
commented
May 29, 2016
One last CI before landing: https://ci.nodejs.org/job/node-test-pull-request/2855/ |
This commit provides a rewrite of StringDecoder that both improves performance (for non-single-byte encodings) and understandability. Additionally, StringDecoder instantiation performance has increased considerably due to inlinability and more efficient encoding name checking. PR-URL: nodejs#6777 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit provides a rewrite of StringDecoder that both improves performance (for non-single-byte encodings) and understandability. Additionally, StringDecoder instantiation performance has increased considerably due to inlinability and more efficient encoding name checking. PR-URL: #6777 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
gagern
commented
Jun 15, 2016
See #7308 for some breakage apparently caused by this change here. |
Checklist
Affected core subsystem(s)
Description of change
This commit provides a rewrite of StringDecoder that both improves performance (for non-single-byte encodings) and understandability.
Additionally, StringDecoder instantiation performance has increased considerably due to inlinability and more efficient encoding name checking.
Benchmark results: