Marcos Casagrande
28142a74dd
perf(ext/headers): optimize getHeader using for loop ( #20115 )
...
This PR optimizes the `getHeader` function by replacing `.filter` and
`.map` with a `for` loop
**this patch**
```
cpu: 13th Gen Intel(R) Core(TM) i9-13900H
runtime: deno 1.36.0 (x86_64-unknown-linux-gnu)
benchmark time (avg) iter/s (min … max) p75 p99 p995
----------------------------------------------------------------- -----------------------------
Headers.get 132.2 ns/iter 7,564,093.4 (125.81 ns … 147.66 ns) 133.79 ns 144.92 ns 145.36 ns
```
**main**
```
cpu: 13th Gen Intel(R) Core(TM) i9-13900H
runtime: deno 1.36.0 (x86_64-unknown-linux-gnu)
benchmark time (avg) iter/s (min … max) p75 p99 p995
----------------------------------------------------------------- -----------------------------
Headers.get 191.48 ns/iter 5,222,523.6 (182.75 ns … 212.22 ns) 193.5 ns 205.96 ns 211.51 ns
```
```js
const headers = new Headers({
"Content-Type": "application/json",
"Date": "Thu, 10 Aug 2023 07:45:10 GMT",
"X-Deno": "Deno",
"Powered-By": "Deno",
"Content-Encoding": "gzip",
"Set-Cookie": "__Secure-ID=123; Secure; Domain=example.com",
"Content-Length": "150",
"Vary": "Accept-Encoding, Accept, X-Requested-With",
});
Deno.bench("Headers.get", () => {
const i = headers.get("x-deno");
});
```
2023-08-21 18:23:27 +05:30
Marcos Casagrande
414274b68a
perf(ext/headers): use .push loop instead of spread operator ( #20108 )
2023-08-09 19:36:47 -04:00
Luca Casonato
d8e8e60f9f
feat(ext/fetch): add Headers#getSetCookie ( #13542 )
...
Spec change: https://github.com/whatwg/fetch/pull/1346
Tests: https://github.com/web-platform-tests/wpt/pull/31442 (ran against
this PR and they all pass)
---------
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-07-02 13:20:56 +02:00
markthree
43d5644048
refactor(ext/fetch): const for max header cache size ( #19496 )
2023-06-15 18:27:21 +02:00
Bartek Iwańczuk
7e81d3c876
perf(http): cache verified headers ( #19465 )
...
Use `Map` to cache validated HTTP headers. Cache
has a capacity of 4096 elements and it's cleared
once that capacity is reached.
In `preactssr` benchmark it lowers the time spent
when adding headers from 180ms to 2.5ms.
2023-06-13 21:13:34 +02:00
Bartek Iwańczuk
21c2c01ebe
perf: optimize RegExp usage in JS ( #19364 )
...
Towards https://github.com/denoland/deno/issues/19330
Shows about 1% improvement in the HTTP benchmark.
2023-06-05 10:52:40 +02:00
Kenta Moriuchi
49eb887cc6
refactor(core): Use ObjectHasOwn
instead of ObjectPrototypeHasOwnProperty
( #18952 )
...
ES2022 `Object.hasOwn` can be used in snapshot, so I migrate to use it.
2023-05-02 12:15:45 +02:00
Leo Kettmeir
b31cf9fde6
refactor(webidl): move prefix & context out of converters options bag ( #18931 )
2023-05-01 10:47:13 +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
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
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
Kenta Moriuchi
55833cf799
fix(core): introduce SafeRegExp
to primordials ( #17592 )
2023-03-01 08:14:16 +09: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
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
0cd05d7377
fix(ext/fetch): fix illegal header regex ( #16236 )
...
This PR fixes invalid header parsing which is flaky because `g` flag is
being used in the regex, which keeps track of `lastIndex`
```javascript
try {
new Headers([["x", "\u0000x"]]); // error
} catch(e) {}
new Headers([["x", "\u0000x"]]); // no error
```
This issue affects `Response` & `Request` constructors as well
2022-10-10 12:06:50 -04:00
Satya Rohith
b312279e58
feat: implement Web Cache API ( #15829 )
2022-09-28 17:41:12 +05:30
apeltop
bb3387de17
chore(ext): fix typo in ext/webgpu, ext/fetch ( #14106 )
2022-03-25 00:36:30 +01:00
Bartek Iwańczuk
bf22f114a6
refactor: update runtime code for primordial check for iterators ( #13510 )
2022-02-07 13:54:32 +01:00
Bartek Iwańczuk
8176a4d166
refactor: primordials for instanceof ( #13527 )
2022-02-01 18:06:11 +01:00
Bartek Iwańczuk
f248e6f177
Revert "refactor: update runtime code for primordial checks for "instanceof" ( #13497 )" ( #13511 )
...
This reverts commit 884143218f
.
2022-01-27 16:27:22 +01:00
Bartek Iwańczuk
884143218f
refactor: update runtime code for primordial checks for "instanceof" ( #13497 )
2022-01-27 13:36:36 +01:00
Ryan Dahl
1fb5858009
chore: update copyright to 2022 ( #13306 )
...
Co-authored-by: Erfan Safari <erfanshield@outlook.com>
2022-01-07 22:09:52 -05:00
Luca Casonato
2eae1ae665
revert: store header keys lower case internally ( #12837 )
...
This reverts commit 49ec3d10ad
.
2021-11-23 01:23:11 +01:00
Aaron O'Mullan
f68825eda0
perf(fetch): optimize fillHeaders() key iteration ( #12287 )
...
Reduces self-time by ~70x (~70ms => ~1ms on 1M iters)
for...in filtered by hasOwnProperty yields the same set of keys as Object.keys()
2021-10-01 12:17:16 +02:00
Aaron O'Mullan
68e5cdaff0
perf(web): ~400x faster http header trimming ( #12277 )
...
Use a regex substring match with a first/last char fastpath instead of 2 regex replaces. Roughly ~400x faster (423ms vs 0.7ms in profiled runs)
2021-09-30 18:39:55 +02:00
Aaron O'Mullan
6c007aa5ab
perf(fetch/headers): optimize appendHeader ( #12234 )
...
Use a single regex to check for `\0`, `\n`, `\r` instead of 3 `String.includes(...)` calls
2021-09-26 20:19:02 +02:00
李瑞丰
46245b830a
fix(ext/webidl): correctly apply [SymbolToStringTag] to interfaces ( #11851 )
...
Co-authored-by: Luca Casonato <hello@lcas.dev>
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2021-09-25 02:07:22 +09:00
Feng Yu
6f63d739ab
fiz(ext/fetch): Headers constructor error message ( #11778 )
2021-08-21 05:07:30 +02:00
Ryan Dahl
a0285e2eb8
Rename extensions/ directory to ext/ ( #11643 )
2021-08-11 12:27:05 +02:00