Shelley Vohr
55e4ca33f3
src: use simdutf for two-byte strings in UTF-8 writes
...
StringBytes::Write() already used simdutf to encode one-byte strings
as UTF-8 but sent every two-byte (UTF-16) string through
v8::String::WriteUtf8V2(), which is several times slower. That path
is behind Buffer.from(string), buf.write(), fs.write*() with string
data and every string written to a libuv stream, and JSON.stringify()
output is a two-byte string as soon as any value in the payload is
outside Latin-1.
Encode two-byte strings with simdutf as well whenever their UTF-8 form
is guaranteed to fit in the target: well-formed input is converted
directly, and input with unpaired surrogates is converted from a copy
passed through simdutf::to_well_formed_utf16(), which replaces each
unpaired surrogate with U+FFFD exactly like kReplaceInvalidUtf8 (this
mirrors what TextEncoder already does). Writes that have to truncate
at a character boundary keep using WriteUtf8V2(), so their output is
byte-for-byte unchanged, and so do strings of up to 32 code units, for
which V8 is already as fast (the same threshold TextEncoder uses).
buf.write() of a 2 KiB two-byte string improves ~5x (astral-heavy and
lone-surrogate strings ~3.5x and ~5x), Buffer.from() of a 64 KiB JSON
string ~2.7x; one-byte strings are unaffected.
Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/65324
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day >
Reviewed-By: Daniel Lemire <daniel@lemire.me >
Reviewed-By: James M Snell <jasnell@gmail.com >
2026-08-18 16:34:15 +00:00
..
2026-08-15 19:05:36 +00:00
2026-08-15 16:47:09 -07:00
2026-08-06 05:50:42 -07:00
2026-08-06 05:50:42 -07:00
2026-08-15 21:59:44 +00:00
2026-08-06 09:25:51 +00:00
2026-08-05 02:17:00 +00:00
2026-08-05 02:17:00 +00:00
2026-08-18 16:34:15 +00:00
2026-08-15 21:59:44 +00:00
2026-08-15 21:59:44 +00:00
2026-08-15 13:15:46 -07:00
2026-08-18 06:20:52 +00:00
2026-08-15 13:15:49 -07:00
2026-08-15 13:17:42 -07:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 17:33:04 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-11 19:34:34 +00:00
2026-08-05 15:38:11 +00:00
2026-08-02 20:18:09 +00:00
2026-08-08 12:18:49 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-08 12:18:49 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-09 08:06:42 +00:00
2026-08-05 15:38:11 +00:00
2026-08-09 19:06:22 -04:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-03 12:49:21 +00:00
2026-08-17 11:08:38 +03:00
2026-08-15 21:59:44 +00:00
2026-08-06 21:24:50 +00:00
2026-08-17 11:08:38 +03:00
2026-08-17 11:08:38 +03:00
2026-08-17 11:08:38 +03:00
2026-08-05 08:18:59 -03:00
2026-08-07 15:06:02 +02:00
2026-08-09 18:56:10 -04:00
2026-08-15 21:59:44 +00:00
2026-08-15 21:59:44 +00:00
2026-08-15 21:59:44 +00:00
2026-08-07 05:19:08 +00:00
2026-08-15 21:59:44 +00:00
2026-08-17 21:03:39 +00:00
2026-08-15 21:59:44 +00:00
2026-08-13 14:36:25 +00:00
2026-08-13 14:36:25 +00:00
2026-08-15 21:59:44 +00:00
2026-08-06 21:24:40 +00:00
2026-08-15 21:59:44 +00:00
2026-08-04 14:01:33 +00:00
2026-08-04 14:01:33 +00:00
2026-08-04 14:01:33 +00:00
2026-08-04 14:01:33 +00:00
2026-08-04 14:01:33 +00:00
2026-08-04 14:01:33 +00:00
2026-08-04 14:01:33 +00:00
2026-08-15 21:59:44 +00:00
2026-08-04 14:01:33 +00:00
2026-08-15 21:59:44 +00:00
2026-08-04 14:01:33 +00:00
2026-08-04 14:01:33 +00:00
2026-08-08 20:43:08 -07:00
2026-08-17 19:01:56 +00:00
2026-08-15 21:59:44 +00:00
2026-08-15 21:59:44 +00:00
2026-08-04 09:07:43 +00:00
2026-08-08 20:43:08 -07:00
2026-08-04 09:07:43 +00:00
2026-08-15 21:59:44 +00:00
2026-08-17 13:03:06 +00:00
2026-08-15 21:59:44 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-03 12:49:09 +00:00
2026-08-14 16:14:48 +00:00
2026-08-02 14:31:00 +00:00
2026-08-05 13:57:32 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 13:54:45 +00:00
2026-08-02 13:54:45 +00:00
2026-08-02 13:54:45 +00:00
2026-08-13 16:34:53 +00:00
2026-08-12 07:41:57 -07:00
2026-08-15 13:15:47 -07:00
2026-08-02 14:31:00 +00:00
2026-08-12 08:58:42 -07:00
2026-08-02 20:18:09 +00:00
2026-08-02 20:18:09 +00:00
2026-08-02 20:18:09 +00:00
2026-08-09 01:18:55 +00:00
2026-08-09 01:18:55 +00:00
2026-08-09 01:18:55 +00:00
2026-08-09 01:18:55 +00:00
2026-08-09 01:18:55 +00:00
2026-08-09 01:18:55 +00:00
2026-08-09 01:18:55 +00:00
2026-08-09 01:18:55 +00:00
2026-08-09 01:18:55 +00:00
2026-08-09 01:18:55 +00:00
2026-08-09 01:18:55 +00:00
2026-08-09 01:18:55 +00:00
2026-08-09 01:18:55 +00:00
2026-08-09 01:18:55 +00:00
2026-08-09 01:18:55 +00:00
2026-08-09 01:18:55 +00:00
2026-08-09 01:18:55 +00:00
2026-08-09 01:18:55 +00:00
2026-08-09 01:18:55 +00:00
2026-08-09 01:18:55 +00:00
2026-08-04 09:07:31 +00:00
2026-08-04 09:07:31 +00:00
2026-08-04 09:07:31 +00:00
2026-08-08 18:42:39 +00:00
2026-08-04 09:07:31 +00:00
2026-08-03 12:49:21 +00:00
2026-08-04 01:45:07 +00:00
2026-08-04 18:32:44 +00:00
2026-08-13 13:26:26 +00:00
2026-08-13 13:26:26 +00:00
2026-08-13 13:26:26 +00:00
2026-08-13 13:26:26 +00:00
2026-08-13 13:26:26 +00:00
2026-08-14 21:43:35 +00:00
2026-08-08 07:29:36 +00:00
2026-08-05 22:50:13 -07:00
2026-08-11 03:14:51 +00:00
2026-08-15 19:42:37 +00:00
2026-08-05 18:10:35 -07:00
2026-08-09 16:26:58 -07:00
2026-08-09 23:03:08 -07:00
2026-08-17 04:01:47 +00:00
2026-08-11 23:47:37 +00:00
2026-08-04 15:03:13 +00:00
2026-08-05 22:43:40 +02:00
2026-08-14 21:43:35 +00:00
2026-08-04 15:03:13 +00:00
2026-08-14 22:44:35 +00:00
2026-08-03 05:29:58 +00:00
2026-08-17 05:02:53 +00:00
2026-08-04 04:58:22 +00:00
2026-08-17 05:02:53 +00:00
2026-08-14 20:50:14 +00:00
2026-08-17 03:39:42 +00:00
2026-08-17 05:02:53 +00:00
2026-08-10 09:06:34 +02:00
2026-08-04 09:07:43 +00:00
2026-08-14 22:44:35 +00:00
2026-08-18 16:34:12 +00:00
2026-08-08 10:57:46 +02:00
2026-08-05 15:38:11 +00:00
2026-08-04 12:33:02 +00:00
2026-08-08 15:05:06 +00:00
2026-08-05 15:38:11 +00:00
2026-08-04 12:33:00 +00:00
2026-08-05 15:38:11 +00:00
2026-08-04 12:33:00 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-02 14:31:00 +00:00
2026-08-13 16:13:28 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-13 21:39:12 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-11 19:34:34 +00:00
2026-08-11 19:34:34 +00:00
2026-08-11 19:34:34 +00:00
2026-08-11 19:34:34 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-08 18:06:56 +00:00
2026-08-05 15:38:11 +00:00
2026-08-11 19:34:34 +00:00
2026-08-11 19:34:34 +00:00
2026-08-05 15:38:11 +00:00
2026-08-11 19:34:34 +00:00
2026-08-13 21:39:12 +00:00
2026-08-13 21:39:12 +00:00
2026-08-11 19:34:34 +00:00
2026-08-05 15:38:11 +00:00
2026-08-05 15:38:11 +00:00
2026-08-13 21:39:12 +00:00
2026-08-05 15:38:11 +00:00
2026-08-11 19:34:34 +00:00
2026-08-13 21:39:12 +00:00
2026-08-13 21:39:12 +00:00
2026-08-05 15:38:11 +00:00
2026-08-13 21:39:12 +00:00
2026-08-13 21:39:12 +00:00
2026-08-08 18:06:56 +00:00
2026-08-11 19:34:34 +00:00
2026-08-04 11:06:00 +00:00
2026-08-17 02:00:16 +00:00
2026-08-05 10:19:53 +00:00
2026-08-15 13:15:47 -07:00
2026-08-14 14:52:07 +00:00
2026-08-14 14:52:07 +00:00
2026-08-14 14:52:07 +00:00
2026-08-14 14:52:07 +00:00
2026-08-14 03:39:42 +00:00
2026-08-14 03:39:45 +00:00
2026-08-14 03:39:42 +00:00
2026-08-14 03:39:40 +00:00
2026-08-12 11:02:57 +02:00
2026-08-08 08:57:54 -04:00
2026-08-14 14:52:07 +00:00