Kenta Moriuchi
c806fbdabe
fix(ext,runtime): add missing custom inspections ( #21219 )
2023-11-19 09:13:38 +01:00
Florian Schwalm
3a7abe6906
fix(ext/web): Prevent TextDecoderStream resource leak on stream cancellation ( #21074 )
...
This PR uses the new `cancel` method of `TransformStream` to properly
clean up the internal `TextDecoder` used in `TextDecoderStream` if the
stream is cancelled.
Fixes #13142
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-11-12 12:47:03 -07:00
Matt Mastracci
9010b8df53
perf: remove knowledge of promise IDs from deno ( #21132 )
...
We can move all promise ID knowledge to deno_core, allowing us to better
experiment with promise implementation in deno_core.
`{un,}refOpPromise(promise)` is equivalent to
`{un,}refOp(promise[promiseIdSymbol])`
2023-11-09 13:57:26 -07:00
Marcos Casagrande
7599990a4f
perf(ext/streams): optimize streams ( #20649 )
...
This PR introduces several optimizations to streams
### Highlights:
- `ReadableStream` constructor: +20% iter/s.
- `WritableStream` constructor: +50% iter/s.
- `TransformStream` constructor: +30% iter/s.
- `ReadableStream` iterator (both 2 and 20 chunks): +42% and +25%
iter/s.
- `ReadableByteStream` iterator (both 2 and 20 chunks): +39% and +20%
iter/s.
### Benchmarks
**main**
```
cpu: 13th Gen Intel(R) Core(TM) i9-13900H
runtime: deno 1.37.0 (x86_64-unknown-linux-gnu)
benchmark time (avg) iter/s (min … max) p75 p99 p995
----------------------------------------------------------------------------------------------- -----------------------------
ReadableStream constructor 294.52 ns/iter 3,395,392.9 (277.92 ns … 618.26 ns) 292.66 ns 353.87 ns 618.26 ns
WritableStream constructor 235.51 ns/iter 4,246,065.3 (213.04 ns … 306.35 ns) 236.77 ns 279.08 ns 281.32 ns
TransformStream constructor 672.52 ns/iter 1,486,938.7 (652.15 ns … 880.74 ns) 670.11 ns 880.74 ns 880.74 ns
ReadableStream - iterator (2 chunks) 10.44 µs/iter 95,757.9 (8.97 µs … 830.91 µs) 10.22 µs 14.74 µs 18.93 µs
ReadableStream - iterator (20 chunks) 21.93 µs/iter 45,593.4 (18.8 µs … 864.97 µs) 20.57 µs 57.15 µs 137.16 µs
ReadableStream - reader (2 chunks) 7.09 µs/iter 140,987.2 (7.03 µs … 7.18 µs) 7.13 µs 7.18 µs 7.18 µs
ReadableStream - reader (20 chunks) 18.41 µs/iter 54,324.2 (15.7 µs … 252.7 µs) 17.14 µs 68.88 µs 94.08 µs
ReadableByteStream - iterator (2 chunks) 11.06 µs/iter 90,375.1 (9.75 µs … 404.69 µs) 10.88 µs 16.6 µs 29.69 µs
ReadableByteStream - iterator (20 chunks) 26.71 µs/iter 37,435.0 (22.98 µs … 508.34 µs) 25.25 µs 85.28 µs 155.65 µs
ReadableByteStream - reader (2 chunks) 7.99 µs/iter 125,131.1 (7.92 µs … 8.13 µs) 8.01 µs 8.13 µs 8.13 µs
ReadableByteStream - reader (20 chunks) 23.46 µs/iter 42,618.5 (20.28 µs … 414.66 µs) 21.94 µs 90.52 µs 147.38 µs
```
**this PR**
```
cpu: 13th Gen Intel(R) Core(TM) i9-13900H
runtime: deno 1.37.0 (x86_64-unknown-linux-gnu)
benchmark time (avg) iter/s (min … max) p75 p99 p995
----------------------------------------------------------------------------------------------- -----------------------------
ReadableStream constructor 235.48 ns/iter 4,246,584.3 (223.12 ns … 504.65 ns) 234.3 ns 290.84 ns 311.12 ns
WritableStream constructor 156.31 ns/iter 6,397,537.3 (148.54 ns … 211.13 ns) 157.49 ns 199.82 ns 208.23 ns
TransformStream constructor 471.29 ns/iter 2,121,815.3 (452.53 ns … 791.41 ns) 468.62 ns 540.36 ns 791.41 ns
ReadableStream - iterator (2 chunks) 7.32 µs/iter 136,705.4 (6.35 µs … 639.97 µs) 7.1 µs 12.12 µs 20.98 µs
ReadableStream - iterator (20 chunks) 17.48 µs/iter 57,195.1 (14.48 µs … 289.06 µs) 16.06 µs 76.98 µs 114.61 µs
ReadableStream - reader (2 chunks) 6.86 µs/iter 145,847.9 (6.8 µs … 6.97 µs) 6.88 µs 6.97 µs 6.97 µs
ReadableStream - reader (20 chunks) 16.88 µs/iter 59,227.7 (14.04 µs … 311.29 µs) 15.39 µs 74.95 µs 97.45 µs
ReadableByteStream - iterator (2 chunks) 7.94 µs/iter 125,881.2 (6.86 µs … 811.16 µs) 7.69 µs 11.43 µs 16.6 µs
ReadableByteStream - iterator (20 chunks) 22.23 µs/iter 44,978.2 (18.98 µs … 590.11 µs) 20.73 µs 45.13 µs 159.8 µs
ReadableByteStream - reader (2 chunks) 7.4 µs/iter 135,206.9 (7.36 µs … 7.42 µs) 7.4 µs 7.42 µs 7.42 µs
ReadableByteStream - reader (20 chunks) 21.03 µs/iter 47,555.6 (17.75 µs … 357.66 µs) 19.52 µs 98.69 µs 146.5 µs
```
---------
Co-authored-by: Luca Casonato <hello@lcas.dev>
2023-10-13 14:30:09 +02:00
Luca Casonato
6450334f5b
feat(ext/web): cancel support for TransformStream ( #20815 )
2023-10-10 18:42:31 +09:00
Luca Casonato
2665ca103e
fix(ext/web): writability of ReadableStream.from
( #20836 )
...
Fixes a WPT in `URL` and `ReadableStream`.
Some unrelated WPT expectation changes due to WPT update.
2023-10-10 05:01:01 +02:00
Matt Mastracci
06297d952d
feat(ext/web): use readableStreamDefaultReaderRead in resourceForReadableStream ( #20622 )
...
We can go one level down in abstraction and avoid using the public
`ReadableStream` APIs.
This patch ~5% perf boost on small ReadableStream:
```
Running 10s test @ http://localhost:8080/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 148.32us 108.95us 3.88ms 95.71%
Req/Sec 33.24k 2.68k 37.94k 73.76%
668188 requests in 10.10s, 77.74MB read
Requests/sec: 66162.91
Transfer/sec: 7.70MB
```
main:
```
Running 10s test @ http://localhost:8080/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 150.23us 67.61us 4.39ms 94.80%
Req/Sec 31.81k 1.55k 35.56k 83.17%
639078 requests in 10.10s, 74.36MB read
Requests/sec: 63273.72
Transfer/sec: 7.36MB
```
2023-09-23 14:55:28 +00:00
Marcos Casagrande
4960b6659c
perf(ext/streams): optimize async iterator ( #20541 )
...
This PR optimizes `ReadableStream` async iterator
### Benchmarks
```js
Deno.bench("Stream - iterator", async () => {
const stream = new ReadableStream({
start(controller) {
controller.enqueue(new Uint8Array([97]));
controller.enqueue(new Uint8Array([97]));
controller.close();
},
});
for await (const chunk of stream) {}
});
```
**main**
`2 chunks`
```
cpu: 13th Gen Intel(R) Core(TM) i9-13900H
runtime: deno 1.36.4 (x86_64-unknown-linux-gnu)
benchmark time (avg) iter/s (min … max) p75 p99 p995
----------------------------------------------------------------------- -----------------------------
Stream - iterator 12.45 µs/iter 80,295.5 (10.5 µs … 281.12 µs) 12.13 µs 26.71 µs 33.63 µs
```
`20 chunks`
```
benchmark time (avg) iter/s (min … max) p75 p99 p995
----------------------------------------------------------------------- -----------------------------
Stream - iterator 32.99 µs/iter 30,312.2 (28.13 µs … 1.21 ms) 31.8 µs 81.82 µs 179.93 µs
```
---
**this PR**
`2 chunks`
```
cpu: 13th Gen Intel(R) Core(TM) i9-13900H
runtime: deno 1.36.4 (x86_64-unknown-linux-gnu)
benchmark time (avg) iter/s (min … max) p75 p99 p995
----------------------------------------------------------------------- -----------------------------
Stream - iterator 9.37 µs/iter 106,700.8 (8.35 µs … 730.71 µs) 9.15 µs 13.12 µs 18.17 µs
```
`20 chunks`
```
benchmark time (avg) iter/s (min … max) p75 p99 p995
----------------------------------------------------------------------- -----------------------------
Stream - iterator 16.59 µs/iter 60,270.0 (12.08 µs … 1.37 ms) 15.06 µs 83.03 µs 123.52 µs
```
2023-09-17 15:54:40 +00:00
David Sherret
3fc19dab47
feat: support import attributes ( #20342 )
2023-09-07 09:09:16 -04:00
Matt Mastracci
9b01307704
fix(ext/web): better handling of errors in resourceForReadableStream ( #20238 )
...
Improves error handling when the Resource is closed in various phases of
the ReadableStream. Ensure that we send a consistent `cancel` reason.
2023-08-22 16:16:34 -06:00
Matt Mastracci
23ff0e722e
feat(ext/web): resourceForReadableStream ( #20180 )
...
Extracted from fast streams work.
This is a resource wrapper for `ReadableStream`, allowing us to treat
all `ReadableStream` instances as resources, and remove special paths in
both `fetch` and `serve`.
Performance with a ReadableStream response yields ~18% improvement:
```
return new Response(new ReadableStream({
start(controller) {
controller.enqueue(new Uint8Array([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]));
controller.close();
}
})
```
This patch:
```
12:36 $ third_party/prebuilt/mac/wrk http://localhost:8080
Running 10s test @ http://localhost:8080
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 99.96us 100.03us 6.65ms 98.84%
Req/Sec 47.73k 2.43k 51.02k 89.11%
959308 requests in 10.10s, 117.10MB read
Requests/sec: 94978.71
Transfer/sec: 11.59MB
```
main:
```
Running 10s test @ http://localhost:8080
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 163.03us 685.51us 19.73ms 99.27%
Req/Sec 39.50k 3.98k 66.11k 95.52%
789582 requests in 10.10s, 82.83MB read
Requests/sec: 78182.65
Transfer/sec: 8.20MB
```
2023-08-17 07:52:37 -06:00
Marcos Casagrande
0fc31d9d65
fix(ext/fetch): clone second branch chunks in Body.clone() ( #20057 )
...
This PR makes `Body.clone()` spec compliant:
https://fetch.spec.whatwg.org/#concept-body-clone
> 1, Let « out1, out2 » be the result of
[teeing](https://streams.spec.whatwg.org/#readablestream-tee ) body’s
[stream](https://fetch.spec.whatwg.org/#concept-body-stream ).
> ...
> To tee a
[ReadableStream](https://streams.spec.whatwg.org/#readablestream )
stream, return ?
[ReadableStreamTee](https://streams.spec.whatwg.org/#readable-stream-tee )(stream,
true).
---
Closes #10994
2023-08-15 09:21:02 +02:00
Leo Kettmeir
805497a9a5
feat: ReadableStream.from ( #19446 )
...
Closes #19417
2023-07-02 19:30:05 +02:00
Kenta Moriuchi
d54ef02dfe
chore: update deno_lint to 0.46.0 ( #19372 )
2023-06-05 15:57:01 -04:00
Kenta Moriuchi
6728ad4203
fix(core): Use primordials for methods ( #18839 )
...
I would like to get this change into Deno before merging
https://github.com/denoland/deno_lint/pull/1152
2023-05-01 15:30:02 +02:00
Leo Kettmeir
b31cf9fde6
refactor(webidl): move prefix & context out of converters options bag ( #18931 )
2023-05-01 10:47:13 +00:00
Leo Kettmeir
59825a95b4
refactor: remove ext/console/01_colors.js ( #18927 )
2023-04-30 09:11:37 +00:00
Bartek Iwańczuk
02da57e275
refactor(ext/webidl): remove option bags from "makeException" ( #18679 )
...
Creating these options bags is more costly than passing arguments
one-by-one. Especially since `prefix` and `context` are passed to all functions.
2023-04-20 00:58:41 +02:00
Kenta Moriuchi
f086ec57b4
fix(core): Use safe primordials wrappers ( #18687 )
2023-04-14 22:23:28 +02:00
Bartek Iwańczuk
a3c5193a2e
refactor(ext/webidl): remove object from 'requiredArguments' ( #18674 )
...
This should produce a little less garbage and using an object here
wasn't really required.
---------
Co-authored-by: Aapo Alasuutari <aapo.alasuutari@gmail.com>
Co-authored-by: Leo Kettmeir <crowlkats@toaxl.com>
2023-04-12 19:58:57 +00:00
Kenta Moriuchi
03edd48edd
chore: Turn back on dlintPreferPrimordials ( #17715 )
...
Closes #17709
2023-04-02 19:41:41 +02:00
Kenta Moriuchi
2b389ecf62
fix(streams): add support Float64Array
to ReadableStreamByobReader
( #18188 )
2023-03-27 15:28:52 +02:00
Bartek Iwańczuk
72fe9bb470
refactor: rename InternalModuleLoader to ExtModuleLoader, use ext: scheme for snapshotted modules ( #18041 )
...
This commit renames "deno_core::InternalModuleLoader" to
"ExtModuleLoader" and changes the specifiers used by the
modules loaded from this loader to "ext:".
"internal:" scheme was really ambiguous and it's more characters than
"ext:", which should result in slightly smaller snapshot size.
Closes https://github.com/denoland/deno/issues/18020
2023-03-08 12:44:54 +01:00
Leo Kettmeir
49af1ab18d
refactor: remove prefix from include_js_files & use extension name ( #17683 )
2023-02-07 21:09:50 +00:00
Leo Kettmeir
b4aa153097
refactor: Use ES modules for internal runtime code ( #17648 )
...
This PR refactors all internal js files (except core) to be written as
ES modules.
`__bootstrap`has been mostly replaced with static imports in form in
`internal:[path to file from repo root]`.
To specify if files are ESM, an `esm` method has been added to
`Extension`, similar to the `js` method.
A new ModuleLoader called `InternalModuleLoader` has been added to
enable the loading of internal specifiers, which is used in all
situations except when a snapshot is only loaded, and not a new one is
created from it.
---------
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-02-07 20:22:46 +01:00
Kenta Moriuchi
6da958d7ec
chore: update dlint to v0.37.0 for GitHub Actions ( #17295 )
...
Updated third_party dlint to v0.37.0 for GitHub Actions. This PR
includes following changes:
* fix(prefer-primordials): Stop using array pattern assignments
* fix(prefer-primordials): Stop using global intrinsics except for
`SharedArrayBuffer`
* feat(guard-for-in): Apply new guard-for-in rule
2023-01-16 17:17:18 +01:00
Kenta Moriuchi
1dc3609ff2
fix(core): Add Generator
and AsyncGenerator
to promordials ( #17241 )
2023-01-15 04:26:05 +00:00
Marcos Casagrande
45768f0e83
fix(ext/web/streams): fix ReadableStream asyncIterator ( #16276 )
2023-01-09 21:17:36 +01:00
Kenta Moriuchi
ff89ff4abb
perf(ext,runtime): remove using SafeArrayIterator
from for-of
( #17255 )
2023-01-06 21:45:23 +09:00
David Sherret
10e4b2e140
chore: update copyright year to 2023 ( #17247 )
...
Yearly tradition of creating extra noise in git.
2023-01-02 21:00:42 +00:00
Kenta Moriuchi
948f85216a
chore: Update dlint ( #17031 )
...
Introduces `SafeSetIterator` and `SafeMapIterator` to primordials
2022-12-20 03:37:50 +01:00
Marcos Casagrande
0832ba1deb
perf(runtime/spawn): collect output using op_read_all
( #16596 )
...
**This patch**
```
benchmark time (avg) (min … max) p75 p99 p995
------------------------------------------------- -----------------------------
echo deno 23.99 ms/iter (22.51 ms … 33.61 ms) 23.97 ms 33.61 ms 33.61 ms
cat 16kb 24.27 ms/iter (22.5 ms … 35.21 ms) 24.2 ms 35.21 ms 35.21 ms
cat 1mb 25.88 ms/iter (25.04 ms … 30.28 ms) 26.12 ms 30.28 ms 30.28 ms
cat 15mb 38.41 ms/iter (35.7 ms … 50 ms) 38.31 ms 50 ms 50 ms
```
**main**
```
benchmark time (avg) (min … max) p75 p99 p995
------------------------------------------------- -----------------------------
echo deno 35.66 ms/iter (34.53 ms … 41.84 ms) 35.79 ms 41.84 ms 41.84 ms
cat 16kb 35.99 ms/iter (34.52 ms … 44.94 ms) 36.05 ms 44.94 ms 44.94 ms
cat 1mb 38.68 ms/iter (36.67 ms … 50.44 ms) 37.95 ms 50.44 ms 50.44 ms
cat 15mb 48.4 ms/iter (46.19 ms … 58.41 ms) 49.16 ms 58.41 ms 58.41 ms
```
2022-11-15 14:06:52 +01:00
Kenta Moriuchi
59ac110edd
fix(core): fix APIs not to be affected by Promise.prototype.then
modification ( #16326 )
2022-10-29 18:25:23 +09:00
Marcos Casagrande
de580cedd2
refactor(ext/streams): remove fake detached ( #16431 )
...
Removed "fake detached" logic since it's no longer needed after
[#16294 ](https://github.com/denoland/deno/pull/16294 ) landed
2022-10-26 20:40:26 +02:00
Divy Srivastava
6cd9343e8b
perf(ext/web): optimize transferArrayBuffer ( #16294 )
...
Avoid copying enqueued data + misc optimizations to skip webidl
converter.
2022-10-26 18:28:25 +05:30
Marcos Casagrande
34fb380ed3
feat(ext/web): use ArrayBuffer.was_detached() ( #16307 )
...
This PR adds a way to reliably check if an ArrayBuffer was detached
2022-10-25 14:22:37 +02:00
Marcos Casagrande
b7d86b4bed
perf(ext/streams): fast path when consuming body of tee'd stream ( #16329 )
...
Add a fast path for consuming the body of cloned `Request`/`Response`,
which is very common specially when using `cache` API.
2022-10-24 13:13:20 +02:00
Marcos Casagrande
e6e2898190
fix(ext/web/streams): enqueue to second branch before closing ( #16269 )
...
Co-authored-by: Luca Casonato <hello@lcas.dev>
2022-10-14 09:51:39 +00:00
Marcos Casagrande
0d6dbc08be
fix(ext/fetch): throw TypeError on non-Uint8Array chunk ( #16262 )
2022-10-14 11:38:17 +02:00
Marcos Casagrande
50c7b89369
fix(ext/web/streams): resolve cancelPromise in ReadableStreamTee ( #16266 )
2022-10-14 11:29:01 +02:00
Luca Casonato
1ab3691b09
feat(core): add Deno.core.writeAll(rid, chunk) ( #16228 )
...
This commit adds a new op_write_all to core that allows writing an
entire chunk in a single async op call. Internally this calls
`Resource::write_all`.
The `writableStreamForRid` has been moved to `06_streams.js` now, and
uses this new op. Various other code paths now also use this new op.
Closes #16227
2022-10-10 10:28:35 +02:00
Marcos Casagrande
cc3e2b9b1a
fix(ext/fetch): reject immediately on aborted signal ( #16190 )
...
Enabled the following test:
edc428e8e2/fetch/api/abort/general.any.js (L185-L201)
2022-10-08 16:08:47 -04:00
Marcos Casagrande
569287b15b
perf(ext/fetch): consume body using ops ( #16038 )
...
This commit adds a fast path to `Request` and `Response` that
make consuming request bodies much faster when using `Body#text`,
`Body#arrayBuffer`, and `Body#blob`, if the body is a FastStream.
Because the response bodies for `fetch` are FastStream, this speeds up
consuming `fetch` response bodies significantly.
2022-10-04 15:48:50 +02:00
Luca Casonato
20c7300412
refactor(ext/http): remove op_http_read ( #16096 )
...
We can use Resource::read_return & op_read instead. This allows HTTP
request bodies to participate in FastStream.
To make this work, `readableStreamForRid` required a change to allow non
auto-closing resources to be handled. This required some minor changes
in our FastStream paths in ext/http and ext/flash.
2022-09-30 07:54:12 +02:00
Luca Casonato
38f544538b
fix(runtime): no FastStream for unrefable streams ( #16095 )
2022-09-30 00:42:33 +02:00
Marcos Casagrande
927f4e2e83
fix(ext/fetch): Body#bodyUsed
for static body ( #16080 )
...
This fixes a bug where `Body#bodyUsed` incorrectly returns `false`
for a body that has actually already been consumed, after `Body#body`
is called.
2022-09-29 17:38:04 +02:00
Divy Srivastava
9e576dff7c
perf(runtime): optimize Deno.file open & stream ( #15496 )
2022-08-19 15:54:40 +05:30
Divy Srivastava
cd21cff299
feat(ext/flash): An optimized http/1.1 server ( #15405 )
...
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl>
Co-authored-by: crowlkats <crowlkats@toaxl.com>
Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
2022-08-18 17:35:02 +05:30
Leo Kettmeir
2bebdc9116
feat(unstable): Ability to ref/unref "Child" in "Deno.spawnChild()" API ( #15151 )
...
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Colin Ihrig <cjihrig@gmail.com>
2022-07-18 22:24:35 +02:00
David Sherret
b4fabedd79
fix(fmt): prevent infinite loop when formatting certain binary expressions ( #14725 )
2022-05-25 19:55:31 -04:00