1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 15:49:44 -05:00
denoland-deno/ext/node/polyfills/internal_binding
Divy Srivastava 1ba88a7892
perf(ext/node): improve Buffer from string performance (#24567)
Fixes https://github.com/denoland/deno/issues/24323

- Use a Buffer pool for `fromString`
- Implement fast call base64 writes
- Direct from string `create` method for each encoding op

```
$ deno bench -A bench.mjs # 1.45.1+fee4d3a
cpu: Apple M1 Pro
runtime: deno 1.45.1+fee4d3a (aarch64-apple-darwin)

benchmark                time (avg)             (min … max)       p75       p99      p999
----------------------------------------------------------- -----------------------------
Buffer.from base64      550 ns/iter     (490 ns … 1'265 ns)    572 ns    606 ns  1'265 ns
Buffer#write base64     285 ns/iter       (259 ns … 371 ns)    307 ns    347 ns    360 ns

$ ~/gh/deno/target/release/deno bench -A bench.mjs # this PR
cpu: Apple M1 Pro
runtime: deno dev (aarch64-apple-darwin)

benchmark                time (avg)             (min … max)       p75       p99      p999
----------------------------------------------------------- -----------------------------
Buffer.from base64      151 ns/iter       (145 ns … 770 ns)    148 ns    184 ns    648 ns
Buffer#write base64   62.58 ns/iter     (60.79 ns … 157 ns)  61.65 ns  75.79 ns    141 ns

$ node bench.mjs # v22.4.0
cpu: Apple M1 Pro
runtime: node v22.4.0 (arm64-darwin)

benchmark                time (avg)             (min … max)       p75       p99      p999
----------------------------------------------------------- -----------------------------
Buffer.from base64      163 ns/iter     (96.92 ns … 375 ns)  99.45 ns    127 ns    220 ns
Buffer#write base64   75.48 ns/iter     (74.97 ns … 134 ns)  75.17 ns  81.83 ns  96.84 ns
```
2024-07-30 18:09:55 +05:30
..
_libuv_winerror.ts refactor: migrate 'ext/node' extension to virtual ops module (#22157) 2024-01-29 14:58:08 +01:00
_listen.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
_node.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
_timingSafeEqual.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
_utils.ts perf(ext/node): improve Buffer from string performance (#24567) 2024-07-30 18:09:55 +05:30
ares.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
async_wrap.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
buffer.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
cares_wrap.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
connection_wrap.ts chore: update deno_lint for CI (#21802) 2024-01-05 15:03:06 +00:00
constants.ts refactor: Use virtul ops module (#22175) 2024-01-29 22:02:26 +01:00
crypto.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
handle_wrap.ts fix(ext/node/net): emit error before close when connection is refused (#24656) 2024-07-24 20:33:45 +09:00
mod.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
node_file.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
node_options.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
pipe_wrap.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
README.md feat(ext/node): embed std/node into the snapshot (#17724) 2023-02-14 17:38:45 +01:00
stream_wrap.ts refactor: migrate 'ext/node' extension to virtual ops module (#22157) 2024-01-29 14:58:08 +01:00
string_decoder.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
symbols.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
tcp_wrap.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
types.ts fix: strict type check for cross realms (#21669) 2024-01-04 09:42:38 +05:30
udp_wrap.ts refactor: migrate 'ext/node' extension to virtual ops module (#22157) 2024-01-29 14:58:08 +01:00
util.ts refactor: migrate 'ext/node' extension to virtual ops module (#22157) 2024-01-29 14:58:08 +01:00
uv.ts fix: android support (#19437) 2024-01-10 06:04:14 -07:00

Internal Bindings

The modules in this directory implement (simulate) C++ bindings implemented in the ./src/ directory of the Node.js repository.

These bindings are created in the Node.js source code by using NODE_MODULE_CONTEXT_AWARE_INTERNAL.

Please refer to https://github.com/nodejs/node/blob/master/src/README.md for further information.