summaryrefslogtreecommitdiff
path: root/ext/websocket/01_websocket.js
AgeCommit message (Collapse)Author
2023-06-08perf(ext/websocket): Reduce GC pressure & monomorpize op_ws_next_event (#19405)Matt Mastracci
Reduce the GC pressure from the websocket event method by splitting it into an event getter and a buffer getter. Before: 165.9k msg/sec After: 169.9k msg/sec
2023-06-07perf(ext/websocket): monomorphize code (#19394)Bartek Iwańczuk
Using `deopt-explorer` I found that a bunch of fields on `WebSocket` class were polymorphic. Fortunately it was enough to initialize them to `undefined` to fix the problem.
2023-06-06perf(ext/websocket): Make send sync for non-stream websockets (#19376)Matt Mastracci
No need to go through the async machinery for `send(String | Buffer)` -- we can fire and forget, and then route any send errors into the async call we're already making (`op_ws_next_event`). Early benchmark on MacOS: Before: 155.8k msg/sec After: 166.2k msg/sec (+6.6%) Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-06-06refactor(core): ensureFastOps is an op-generating proxy (#19377)Matt Mastracci
Startup benchmark shows no changes (within 1ms, identical system/user times).
2023-06-05chore: update deno_lint to 0.46.0 (#19372)Kenta Moriuchi
2023-06-05perf: optimize RegExp usage in JS (#19364)Bartek Iwańczuk
Towards https://github.com/denoland/deno/issues/19330 Shows about 1% improvement in the HTTP benchmark.
2023-05-01refactor: migrate async ops to generated wrappers (#18937)Bartek Iwańczuk
Migrates some of existing async ops to generated wrappers introduced in https://github.com/denoland/deno/pull/18887. As a result "core.opAsync2" was removed. I will follow up with more PRs that migrate all the async ops to generated wrappers.
2023-05-01refactor(webidl): move prefix & context out of converters options bag (#18931)Leo Kettmeir
2023-04-30perf(ext/websocket): use internal dispatch for msg events (#18904)Divy Srivastava
``` Linux divy-2 5.19.0-1022-gcp #24~22.04.1-Ubuntu SMP Sun Apr 23 09:51:08 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux 32GiB System memory Intel(R) Xeon(R) CPU @ 3.10GHz # main Msg/sec: 89398.250000 Msg/sec: 90079.750000 # this patch Msg/sec: 91919.750000 Msg/sec: 91762.250000 ```
2023-04-27perf(ext/websocket): various performance improvements (#18862)Bartek Iwańczuk
- No need to wrap buffer in a `new DataView()` - Deferred ops are still eagerly polled, but resolved on the next tick of the event loop, we don't want them to be eagerly polled - Using "core.opAsync"/"core.opAsync2" incurs additional cost of looking up these functions on each call. Similarly with "ops.*" --------- Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-04-26chore(ext/websocket): remove ping frame handling (#18847)Divy Srivastava
Automatically done in the fastwebsockets crate
2023-04-25refactor(ext/websocket): use specialized ops (#18819)Bartek Iwańczuk
Instead of relying on `op_ws_send` to send different kinds of messages, use specialized ops everywhere.
2023-04-20refactor(ext/websocket): use fastwebsockets client (#18725)Divy Srivastava
2023-04-14fix(core): Use safe primordials wrappers (#18687)Kenta Moriuchi
2023-04-12refactor(ext/webidl): remove object from 'requiredArguments' (#18674)Bartek Iwańczuk
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-06perf(ext/websocket): replace tokio_tungstenite server with fastwebsockets ↵Divy Srivastava
(#18587) https://github.com/littledivy/fastwebsockets ``` # This PR ./load_test 100 0.0.0.0 8080 0 0 Running benchmark now... Msg/sec: 176355.000000 # main ./load_test 100 0.0.0.0 8080 0 0 Running benchmark now... Msg/sec: 157198.750000 ```
2023-04-02chore: Turn back on dlintPreferPrimordials (#17715)Kenta Moriuchi
Closes #17709
2023-03-31perf(ext/websocket): use opAsync2 to avoid spread deopt (#18525)Divy Srivastava
This commit adds a new core API `opAsync2` to call an async op with atmost 2 arguments. Spread argument iterators has a pretty big perf hit when calling ops. | name | avg msg/sec/core | | --- | --- | | 1.32.1 | `127820.750000` | | #18506 | `140079.000000` | | #18506 + #18509 | `150104.250000` | | #18506 + #18509 + this | `157340.000000` |
2023-03-31perf(ext/websocket): efficient event kind serialization (#18509)Divy Srivastava
Use u16 to represent the kind of event (0 - 6) & event code > 6 is treated as the close code. This way we can represent all events + the close code in a single JS number. This is safe because (as per RFC 6455) close code from 0-999 are reserved & not used. | name | avg msg/sec/core | | --- | --- | | deno_main | `127820.750000` | | deno #18506 | `140079.000000` | | deno #18506 + this | `150104.250000` |
2023-03-30perf(ext/websocket): special op for sending binary data frames (#18506)Divy Srivastava
Easy perf win by avoiding deserializing `SendValue` through serde_v8. | name | avg msg/sec/core | | --- | --- | | deno_main | `127820.750000` | | deno_this | `140079.000000` |
2023-03-30perf(ext/websocket): special op for sending text data frames (#18507)Divy Srivastava
Similar to #18506 but for Text frames.
2023-03-08refactor: rename InternalModuleLoader to ExtModuleLoader, use ext: scheme ↵Bartek Iwańczuk
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-02-13fix(ext/websocket): extra ws pongs sent (#17762)Divy Srivastava
Fixes https://github.com/denoland/deno/issues/17761 Tugstenite already sends a pong for a recieved ping. This automatically happens when the socket read is being driven. From https://github.com/snapview/tokio-tungstenite/issues/88 > You need to read from the read-side of the socket so that it receives/handles pings, and on the next write it would then send the corresponding pong. Here's the source: https://github.com/snapview/tungstenite-rs/blob/e1033afd959bb7abfcbc181033b8326f8a40562b/src/protocol/mod.rs#L374-L380 ```rust // Upon receipt of a Ping frame, an endpoint MUST send a Pong frame in // response, unless it already received a Close frame. It SHOULD // respond with Pong frame as soon as is practical. (RFC 6455) if let Some(pong) = self.pong.take() { trace!("Sending pong reply"); self.send_one_frame(stream, pong)?; } ``` WIth this patch, all Autobahn tests from 1-8 pass. Fixed cases: 2.1, 2.2, 2.3, 2.4, 2.6, 2.9, 2.10, 2.11, 5.6, 5.7, 5.8, 5.19, 5.20 To run the test yourself, follow https://www.notion.so/denolandinc/Autobahn-WebSocket-testsuite-723a86f450ce4823b4ef9cb3dc4c7869?pvs=4
2023-02-07 refactor: remove prefix from include_js_files & use extension name (#17683)Leo Kettmeir
2023-02-07refactor: Use ES modules for internal runtime code (#17648)Leo Kettmeir
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-01-20Revert "perf(ext/websocket): optimize socket.send (#16320)" (#17480)Leo Kettmeir
This reverts commit 36307c45
2023-01-16chore: update dlint to v0.37.0 for GitHub Actions (#17295)Kenta Moriuchi
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-02chore: update copyright year to 2023 (#17247)David Sherret
Yearly tradition of creating extra noise in git.
2022-12-01perf(ext/websocket): skip Events constructor checks (#16365)Divy Srivastava
WebSocket internal events can bypass Event's webidl checks and `ReflectDefineProperty` on the object value. Note, this intentionally makes websocket events `isTrusted` configurable (not spec-compliant) which hurts performance a lot. Before: ``` Msg/sec: 167627.750000 Msg/sec: 168239.250000 Msg/sec: 169690.000000 ``` After: ``` Msg/sec: 191065.500000 Msg/sec: 194745.250000 Msg/sec: 194746.000000 ```
2022-11-01revert 9ea0ce61981aa09851c3d1e0a2b7dbd7f7a392f5 (#16501)Bartek Iwańczuk
Closes https://github.com/denoland/deno/issues/16450
2022-10-24experiment(ext/web): Don't expose event classes during the bootstrap phase ↵Andreu Botella
(#16213)
2022-10-20perf(serde_v8): `serde_v8::StringOrBuffer` return JS ArrayBuffer instead of ↵Divy Srivastava
Uint8Array (#16360) Towards #16315
2022-10-19perf(ext/websocket): optimize `op_ws_next_event` (#16325)Divy Srivastava
Towards https://github.com/denoland/deno/issues/16315
2022-10-19perf(ext/websocket): optimize socket.send (#16320)Divy Srivastava
Towards #16315
2022-09-27feat: Add requesting API name to permission prompt (#15936)Bartek Iwańczuk
Co-authored-by: Leo Kettmeir <crowlkats@toaxl.com>
2022-08-11perf(ops): Monomorphic sync op calls (#15337)Aapo Alasuutari
Welcome to better optimised op calls! Currently opSync is called with parameters of every type and count. This most definitely makes the call megamorphic. Additionally, it seems that spread params leads to V8 not being able to optimise the calls quite as well (apparently Fast Calls cannot be used with spread params). Monomorphising op calls should lead to some improved performance. Now that unwrapping of sync ops results is done on Rust side, this is pretty simple: ``` opSync("op_foo", param1, param2); // -> turns to ops.op_foo(param1, param2); ``` This means sync op calls are now just directly calling the native binding function. When V8 Fast API Calls are enabled, this will enable those to be called on the optimised path. Monomorphising async ops likely requires using callbacks and is left as an exercise to the reader.
2022-06-08fix(http/upgradewebsocket): check for open state for idle timeout (#14813)Leo Kettmeir
2022-05-23fix(ext/websocket): WebSocket dispatch single close event (#13443)Leo Kettmeir
2022-04-04chore(ext/websocket): custom arity (#14202)Divy Srivastava
2022-02-01refactor: primordials for instanceof (#13527)Bartek Iwańczuk
2022-01-27Revert "refactor: update runtime code for primordial checks for "instanceof" ↵Bartek Iwańczuk
(#13497)" (#13511) This reverts commit 884143218fad0e18f7553aaf079d52de703f7601.
2022-01-27refactor: update runtime code for primordial checks for "instanceof" (#13497)Bartek Iwańczuk
2022-01-07chore: update copyright to 2022 (#13306)Ryan Dahl
Co-authored-by: Erfan Safari <erfanshield@outlook.com>
2022-01-06feat(ext/websocket): server automatically handle ping/pong for incoming ↵Leo Kettmeir
WebSocket (#13172)
2021-10-19fix(ext/websocket): prevent 'closed normally' panic (#12437)Leo K
2021-10-08refactor: deduplicate `defineEventHandler` util (#12367)Andreu Botella
2021-10-05chore: various op cleanup (#12329)Leo K
2021-09-11refactor: use Deno.core.tryClose (#11980)Bartek Iwańczuk
2021-08-11Rename extensions/ directory to ext/ (#11643)Ryan Dahl