<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/node-new.git/src/node_external_reference.h, branch main</title>
<subtitle>github.com: nodejs/node.git
</subtitle>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/node-new.git/'/>
<entry>
<title>src: register external references for source code</title>
<updated>2023-05-10T11:17:59+00:00</updated>
<author>
<name>Keyhan Vakil</name>
<email>kvakil@sylph.kvakil.me</email>
</author>
<published>2023-05-10T11:17:59+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/node-new.git/commit/?id=0736d0b3f520acbd32701899056966a25db1924b'/>
<id>0736d0b3f520acbd32701899056966a25db1924b</id>
<content type='text'>
Currently we use external strings for internalized builtin source code.
However when a snapshot is taken, any external string whose resource
is not registered is flattened into a SeqString (see ref). The
result is that module source code stored in the snapshot does not
use external strings after deserialization. This patch registers an
external string resource for each internalized builtin's source. The
savings are substantial: ~1.9 MB of heap memory per isolate, or ~44%
of an otherwise empty isolate's heap usage:

```console
$ node --expose-gc -p 'gc(),process.memoryUsage().heapUsed'
4190968
$ ./node --expose-gc -p 'gc(),process.memoryUsage().heapUsed'
2327536
```

The savings can be even higher for user snapshots which may include
more internal modules.

The existing UnionBytes implementation was ill-suited, because it only
created an external string resource when ToStringChecked was called,
but we need to register the external string resources before the
isolate even exists. We change UnionBytes to no longer own the data,
and shift ownership of the data to a new external resource class
called StaticExternalByteResource.  StaticExternalByteResource are
either statically allocated (for internalized builtin code) or owned
by the static `externalized_builtin_sources` map, so they will only be
destructed when static resources are destructed. We change JS2C to emit
statements to register a string resource for each internalized builtin.

Refs: https://github.com/v8/v8/blob/d2c8fbe9ccd1a6ce5591bb7dd319c3c00d6bf489/src/snapshot/serializer.cc#L633
PR-URL: https://github.com/nodejs/node/pull/47055
Reviewed-By: Joyee Cheung &lt;joyeec9h3@gmail.com&gt;
Reviewed-By: Chengzhong Wu &lt;legendecas@gmail.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Currently we use external strings for internalized builtin source code.
However when a snapshot is taken, any external string whose resource
is not registered is flattened into a SeqString (see ref). The
result is that module source code stored in the snapshot does not
use external strings after deserialization. This patch registers an
external string resource for each internalized builtin's source. The
savings are substantial: ~1.9 MB of heap memory per isolate, or ~44%
of an otherwise empty isolate's heap usage:

```console
$ node --expose-gc -p 'gc(),process.memoryUsage().heapUsed'
4190968
$ ./node --expose-gc -p 'gc(),process.memoryUsage().heapUsed'
2327536
```

The savings can be even higher for user snapshots which may include
more internal modules.

The existing UnionBytes implementation was ill-suited, because it only
created an external string resource when ToStringChecked was called,
but we need to register the external string resources before the
isolate even exists. We change UnionBytes to no longer own the data,
and shift ownership of the data to a new external resource class
called StaticExternalByteResource.  StaticExternalByteResource are
either statically allocated (for internalized builtin code) or owned
by the static `externalized_builtin_sources` map, so they will only be
destructed when static resources are destructed. We change JS2C to emit
statements to register a string resource for each internalized builtin.

Refs: https://github.com/v8/v8/blob/d2c8fbe9ccd1a6ce5591bb7dd319c3c00d6bf489/src/snapshot/serializer.cc#L633
PR-URL: https://github.com/nodejs/node/pull/47055
Reviewed-By: Joyee Cheung &lt;joyeec9h3@gmail.com&gt;
Reviewed-By: Chengzhong Wu &lt;legendecas@gmail.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>src: add v8 fast api for url canParse</title>
<updated>2023-04-20T16:16:21+00:00</updated>
<author>
<name>Khafra</name>
<email>maitken033380023@gmail.com</email>
</author>
<published>2023-04-20T16:16:21+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/node-new.git/commit/?id=6675505686310771b8016805a381945826aad887'/>
<id>6675505686310771b8016805a381945826aad887</id>
<content type='text'>
PR-URL: https://github.com/nodejs/node/pull/47552
Reviewed-By: Yagiz Nizipli &lt;yagiz@nizipli.com&gt;
Reviewed-By: Mohammed Keyvanzadeh &lt;mohammadkeyvanzade94@gmail.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
PR-URL: https://github.com/nodejs/node/pull/47552
Reviewed-By: Yagiz Nizipli &lt;yagiz@nizipli.com&gt;
Reviewed-By: Mohammed Keyvanzadeh &lt;mohammadkeyvanzade94@gmail.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>src: move encoding bindings to a new binding</title>
<updated>2023-03-07T21:45:42+00:00</updated>
<author>
<name>Joyee Cheung</name>
<email>joyeec9h3@gmail.com</email>
</author>
<published>2023-02-11T17:54:35+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/node-new.git/commit/?id=25c21868b8d16392835454f57bb465157661f199'/>
<id>25c21868b8d16392835454f57bb465157661f199</id>
<content type='text'>
Move the bindings used by TextEncoder to a new binding for
more self-contained code.

PR-URL: https://github.com/nodejs/node/pull/46658
Reviewed-By: Darshan Sen &lt;raisinten@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Move the bindings used by TextEncoder to a new binding for
more self-contained code.

PR-URL: https://github.com/nodejs/node/pull/46658
Reviewed-By: Darshan Sen &lt;raisinten@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>timers: use V8 fast API calls</title>
<updated>2023-02-28T09:37:24+00:00</updated>
<author>
<name>Joyee Cheung</name>
<email>joyeec9h3@gmail.com</email>
</author>
<published>2023-02-28T09:37:24+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/node-new.git/commit/?id=1101713cc2dd20a141781083aa385c1294df6708'/>
<id>1101713cc2dd20a141781083aa385c1294df6708</id>
<content type='text'>
PR-URL: https://github.com/nodejs/node/pull/46579
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Yagiz Nizipli &lt;yagiz@nizipli.com&gt;
Reviewed-By: Robert Nagy &lt;ronagy@icloud.com&gt;
Reviewed-By: Matteo Collina &lt;matteo.collina@gmail.com&gt;
Reviewed-By: Darshan Sen &lt;raisinten@gmail.com&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: Tobias Nießen &lt;tniessen@tnie.de&gt;
Reviewed-By: Benjamin Gruenbaum &lt;benjamingr@gmail.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
PR-URL: https://github.com/nodejs/node/pull/46579
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Yagiz Nizipli &lt;yagiz@nizipli.com&gt;
Reviewed-By: Robert Nagy &lt;ronagy@icloud.com&gt;
Reviewed-By: Matteo Collina &lt;matteo.collina@gmail.com&gt;
Reviewed-By: Darshan Sen &lt;raisinten@gmail.com&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: Tobias Nießen &lt;tniessen@tnie.de&gt;
Reviewed-By: Benjamin Gruenbaum &lt;benjamingr@gmail.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>buffer: use v8 fast API calls for `Buffer.byteLength` implementation</title>
<updated>2023-02-26T18:02:45+00:00</updated>
<author>
<name>Joyee Cheung</name>
<email>joyeec9h3@gmail.com</email>
</author>
<published>2023-02-11T16:49:32+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/node-new.git/commit/?id=ee1ce1872ff38fc5a2fd3b2e3a97600e5d6b2e14'/>
<id>ee1ce1872ff38fc5a2fd3b2e3a97600e5d6b2e14</id>
<content type='text'>
Use v8 fast API calls for Buffer.byteLength with sequential one-byte
strings.

PR-URL: https://github.com/nodejs/node/pull/46616
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Robert Nagy &lt;ronagy@icloud.com&gt;
Reviewed-By: Yagiz Nizipli &lt;yagiz@nizipli.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use v8 fast API calls for Buffer.byteLength with sequential one-byte
strings.

PR-URL: https://github.com/nodejs/node/pull/46616
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Robert Nagy &lt;ronagy@icloud.com&gt;
Reviewed-By: Yagiz Nizipli &lt;yagiz@nizipli.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>src,process: add permission model</title>
<updated>2023-02-23T18:11:51+00:00</updated>
<author>
<name>Rafael Gonzaga</name>
<email>rafael.nunu@hotmail.com</email>
</author>
<published>2023-02-23T18:11:51+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/node-new.git/commit/?id=00c222593e49d817281bc88a322f41f8dca95885'/>
<id>00c222593e49d817281bc88a322f41f8dca95885</id>
<content type='text'>
Signed-off-by: RafaelGSS &lt;rafael.nunu@hotmail.com&gt;
PR-URL: https://github.com/nodejs/node/pull/44004
Reviewed-By: Gireesh Punathil &lt;gpunathi@in.ibm.com&gt;
Reviewed-By: Matteo Collina &lt;matteo.collina@gmail.com&gt;
Reviewed-By: Michaël Zasso &lt;targos@protonmail.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Paolo Insogna &lt;paolo@cowtech.it&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: RafaelGSS &lt;rafael.nunu@hotmail.com&gt;
PR-URL: https://github.com/nodejs/node/pull/44004
Reviewed-By: Gireesh Punathil &lt;gpunathi@in.ibm.com&gt;
Reviewed-By: Matteo Collina &lt;matteo.collina@gmail.com&gt;
Reviewed-By: Michaël Zasso &lt;targos@protonmail.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Paolo Insogna &lt;paolo@cowtech.it&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>src: add initial support for single executable applications</title>
<updated>2023-02-18T02:49:18+00:00</updated>
<author>
<name>Darshan Sen</name>
<email>raisinten@gmail.com</email>
</author>
<published>2023-02-18T02:49:18+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/node-new.git/commit/?id=9bbde3d7baef584f14569ef79f116e9d288c7aaa'/>
<id>9bbde3d7baef584f14569ef79f116e9d288c7aaa</id>
<content type='text'>
Compile a JavaScript file into a single executable application:

```console
$ echo 'console.log(`Hello, ${process.argv[2]}!`);' &gt; hello.js

$ cp $(command -v node) hello

$ npx postject hello NODE_JS_CODE hello.js \
    --sentinel-fuse NODE_JS_FUSE_fce680ab2cc467b6e072b8b5df1996b2

$ npx postject hello NODE_JS_CODE hello.js \
    --sentinel-fuse NODE_JS_FUSE_fce680ab2cc467b6e072b8b5df1996b2 \
    --macho-segment-name NODE_JS

$ ./hello world
Hello, world!
```

Signed-off-by: Darshan Sen &lt;raisinten@gmail.com&gt;
PR-URL: https://github.com/nodejs/node/pull/45038
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Michael Dawson &lt;midawson@redhat.com&gt;
Reviewed-By: Joyee Cheung &lt;joyeec9h3@gmail.com&gt;
Reviewed-By: Matteo Collina &lt;matteo.collina@gmail.com&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Compile a JavaScript file into a single executable application:

```console
$ echo 'console.log(`Hello, ${process.argv[2]}!`);' &gt; hello.js

$ cp $(command -v node) hello

$ npx postject hello NODE_JS_CODE hello.js \
    --sentinel-fuse NODE_JS_FUSE_fce680ab2cc467b6e072b8b5df1996b2

$ npx postject hello NODE_JS_CODE hello.js \
    --sentinel-fuse NODE_JS_FUSE_fce680ab2cc467b6e072b8b5df1996b2 \
    --macho-segment-name NODE_JS

$ ./hello world
Hello, world!
```

Signed-off-by: Darshan Sen &lt;raisinten@gmail.com&gt;
PR-URL: https://github.com/nodejs/node/pull/45038
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Michael Dawson &lt;midawson@redhat.com&gt;
Reviewed-By: Joyee Cheung &lt;joyeec9h3@gmail.com&gt;
Reviewed-By: Matteo Collina &lt;matteo.collina@gmail.com&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>bootstrap: support module_wrap binding in snapshot</title>
<updated>2022-12-16T11:43:49+00:00</updated>
<author>
<name>Joyee Cheung</name>
<email>joyeec9h3@gmail.com</email>
</author>
<published>2022-12-13T20:59:14+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/node-new.git/commit/?id=579235747ed3b7500c19b3c2c407c80759236653'/>
<id>579235747ed3b7500c19b3c2c407c80759236653</id>
<content type='text'>
PR-URL: https://github.com/nodejs/node/pull/45849
Reviewed-By: Geoffrey Booth &lt;webadmin@geoffreybooth.com&gt;
Reviewed-By: Chengzhong Wu &lt;legendecas@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
PR-URL: https://github.com/nodejs/node/pull/45849
Reviewed-By: Geoffrey Booth &lt;webadmin@geoffreybooth.com&gt;
Reviewed-By: Chengzhong Wu &lt;legendecas@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>src: rename internal module declaration as internal bindings</title>
<updated>2022-11-28T16:23:08+00:00</updated>
<author>
<name>legendecas</name>
<email>legendecas@gmail.com</email>
</author>
<published>2022-11-20T17:37:56+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/node-new.git/commit/?id=71ff89f9299d1d10a4c424da23d827e5458dadff'/>
<id>71ff89f9299d1d10a4c424da23d827e5458dadff</id>
<content type='text'>
This is a continuation of the name reification on the internal bindings.

Renames NODE_MODULE_CONTEXT_AWARE_INTERNAL and
NODE_MODULE_EXTERNAL_REFERENCE to NODE_BINDING_CONTEXT_AWARE_INTERNAL
and NODE_BINDING_EXTERNAL_REFERENCE respectively.

PR-URL: https://github.com/nodejs/node/pull/45551
Refs: https://github.com/nodejs/node/issues/44036
Reviewed-By: Joyee Cheung &lt;joyeec9h3@gmail.com&gt;
Reviewed-By: Rafael Gonzaga &lt;rafael.nunu@hotmail.com&gt;
Reviewed-By: Daeyeon Jeong &lt;daeyeon.dev@gmail.com&gt;
Reviewed-By: Jacob Smith &lt;jacob@frende.me&gt;
Reviewed-By: Yagiz Nizipli &lt;yagiz@nizipli.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is a continuation of the name reification on the internal bindings.

Renames NODE_MODULE_CONTEXT_AWARE_INTERNAL and
NODE_MODULE_EXTERNAL_REFERENCE to NODE_BINDING_CONTEXT_AWARE_INTERNAL
and NODE_BINDING_EXTERNAL_REFERENCE respectively.

PR-URL: https://github.com/nodejs/node/pull/45551
Refs: https://github.com/nodejs/node/issues/44036
Reviewed-By: Joyee Cheung &lt;joyeec9h3@gmail.com&gt;
Reviewed-By: Rafael Gonzaga &lt;rafael.nunu@hotmail.com&gt;
Reviewed-By: Daeyeon Jeong &lt;daeyeon.dev@gmail.com&gt;
Reviewed-By: Jacob Smith &lt;jacob@frende.me&gt;
Reviewed-By: Yagiz Nizipli &lt;yagiz@nizipli.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>dns: support dns module in the snapshot</title>
<updated>2022-09-28T17:58:21+00:00</updated>
<author>
<name>Joyee Cheung</name>
<email>joyeec9h3@gmail.com</email>
</author>
<published>2022-09-14T07:08:26+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/node-new.git/commit/?id=8821860f11a94e69ba642d874d3226480a68fc1b'/>
<id>8821860f11a94e69ba642d874d3226480a68fc1b</id>
<content type='text'>
For the initial iteration, only the default resolver can be
serialized/deserialized. If `dns.setServers()` has been
called, we'll preserve the configured DNS servers in the snapshot.
We can consider exposing the serialization method if it becomes
necessary for user-land snapshots.

PR-URL: https://github.com/nodejs/node/pull/44633
Reviewed-By: Matteo Collina &lt;matteo.collina@gmail.com&gt;
Reviewed-By: Antoine du Hamel &lt;duhamelantoine1995@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
For the initial iteration, only the default resolver can be
serialized/deserialized. If `dns.setServers()` has been
called, we'll preserve the configured DNS servers in the snapshot.
We can consider exposing the serialization method if it becomes
necessary for user-land snapshots.

PR-URL: https://github.com/nodejs/node/pull/44633
Reviewed-By: Matteo Collina &lt;matteo.collina@gmail.com&gt;
Reviewed-By: Antoine du Hamel &lt;duhamelantoine1995@gmail.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
