forked from aiko-chan-ai/Discord-video-experiment
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup various parts of the library (#150)
* Remove `streamLivestreamVideo` * Stop exposing `(Audio|Video)Stream` * Move `setProtocols` call back into `BaseMediaConnection` User shouldn't be calling this anyway * Remove problematic `streamOptions`, move force Chacha20 options to `Streamer` Moving the Chacha20 options to the Streamer class is probably a good move, since it's unlikely that anyone would want 2 separate encryption methods for the 2 streams * Remove the `forceChacha20Encryption` option in `playStream` * Expose new API as top level exports * Pass SSRC through constructor * Move `rtcpSenderReportEnabled` option to Streamer, make RTCP interval time-based * Fix README * Remove old basic example * Add `noTranscoding` option to README * Remove `custom-stream-copy-codec` example The functionality is now built in to the library * Update `puppeteer-stream` example Untested, but I don't see why it shouldn't work * Add newlines to fix IDE docs * Document `playStream` options, specify where to change streamer options * Add optional specifier to `playStream` options * Move `sendOpcode` call outside of promise creation * Fix incorrect logic * Revert "Move `sendOpcode` call outside of promise creation" Due to some unknown causes, the event ends up firing before the handler is attached * How did this happen... * Update streamer options * Add performance tips * Remove leftover `srInterval` override * Use `crypto` global instead of importing `node:crypto`
- Loading branch information
1 parent
4bb49e8
commit 9537628
Showing
30 changed files
with
467 additions
and
1,170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Performance related tweaks | ||
|
||
## Transport encryption methods | ||
|
||
On CPUs without AES acceleration (very old x86 CPUs, certain ARM SoCs on single board computers, certain VMs that don't expose AES acceleration capability), the default encryption method (AES-256-GCM) might not be fast enough to handle high frame-rate + high bitrate streams. | ||
|
||
In such cases, you can enable the `forceChacha20Encryption` option on the `Streamer` instance (`streamer.opts.forceChacha20Encryption = true`) before starting a stream, to force the use of the faster Chacha20-Poly1305 encryption method. For even higher performance, also install the optional [`sodium-native`](https://www.npmjs.com/package/sodium-native) package to use the faster native version instead of the WASM version. | ||
|
||
Below are some benchmark results of the two encryption methods in various circumstances, for reference purposes only. All benchmarks are performed on a Ryzen 5 5600H. | ||
|
||
<details> | ||
<summary>AES-256-GCM, with AES acceleration</summary> | ||
|
||
``` | ||
PS C:\> openssl speed -elapsed -aead -evp aes-256-gcm | ||
You have chosen to measure elapsed time instead of user CPU time. | ||
Doing AES-256-GCM ops for 3s on 2 size blocks: 19046296 AES-256-GCM ops in 3.00s | ||
Doing AES-256-GCM ops for 3s on 31 size blocks: 15299030 AES-256-GCM ops in 3.00s | ||
Doing AES-256-GCM ops for 3s on 136 size blocks: 13580376 AES-256-GCM ops in 3.00s | ||
Doing AES-256-GCM ops for 3s on 1024 size blocks: 7691855 AES-256-GCM ops in 3.00s | ||
Doing AES-256-GCM ops for 3s on 8192 size blocks: 1648811 AES-256-GCM ops in 3.00s | ||
Doing AES-256-GCM ops for 3s on 16384 size blocks: 863115 AES-256-GCM ops in 3.00s | ||
version: 3.4.0 | ||
built on: Tue Oct 22 23:27:41 2024 UTC | ||
options: bn(64,64) | ||
compiler: cl /Z7 /Fdossl_static.pdb /Gs0 /GF /Gy /MD /W3 /wd4090 /nologo /O2 -DL_ENDIAN -DOPENSSL_PIC -D"OPENSSL_BUILDING_OPENSSL" -D"OPENSSL_SYS_WIN32" -D"WIN32_LEAN_AND_MEAN" -D"UNICODE" -D"_UNICODE" -D"_CRT_SECURE_NO_DEPRECATE" -D"_WINSOCK_DEPRECATED_NO_WARNINGS" -D"NDEBUG" -D_WINSOCK_DEPRECATED_NO_WARNINGS -D_WIN32_WINNT=0x0502 | ||
CPUINFO: OPENSSL_ia32cap=0xfed8320b078bffff:0x400684219c97a9 | ||
The 'numbers' are in 1000s of bytes per second processed. | ||
type 2 bytes 31 bytes 136 bytes 1024 bytes 8192 bytes 16384 bytes | ||
AES-256-GCM 12693.30k 158089.98k 615233.56k 2625486.51k 4500852.95k 4712187.99k | ||
``` | ||
|
||
</details> | ||
|
||
<details> | ||
<summary>AES-256-GCM, without AES acceleration</summary> | ||
|
||
``` | ||
PS C:\> openssl speed -elapsed -aead -evp aes-256-gcm | ||
You have chosen to measure elapsed time instead of user CPU time. | ||
Doing AES-256-GCM ops for 3s on 2 size blocks: 6947831 AES-256-GCM ops in 3.00s | ||
Doing AES-256-GCM ops for 3s on 31 size blocks: 4875037 AES-256-GCM ops in 3.00s | ||
Doing AES-256-GCM ops for 3s on 136 size blocks: 3132696 AES-256-GCM ops in 3.00s | ||
Doing AES-256-GCM ops for 3s on 1024 size blocks: 821006 AES-256-GCM ops in 3.00s | ||
Doing AES-256-GCM ops for 3s on 8192 size blocks: 113769 AES-256-GCM ops in 3.00s | ||
Doing AES-256-GCM ops for 3s on 16384 size blocks: 57074 AES-256-GCM ops in 3.00s | ||
version: 3.4.0 | ||
built on: Tue Oct 22 23:27:41 2024 UTC | ||
options: bn(64,64) | ||
compiler: cl /Z7 /Fdossl_static.pdb /Gs0 /GF /Gy /MD /W3 /wd4090 /nologo /O2 -DL_ENDIAN -DOPENSSL_PIC -D"OPENSSL_BUILDING_OPENSSL" -D"OPENSSL_SYS_WIN32" -D"WIN32_LEAN_AND_MEAN" -D"UNICODE" -D"_UNICODE" -D"_CRT_SECURE_NO_DEPRECATE" -D"_WINSOCK_DEPRECATED_NO_WARNINGS" -D"NDEBUG" -D_WINSOCK_DEPRECATED_NO_WARNINGS -D_WIN32_WINNT=0x0502 | ||
CPUINFO: OPENSSL_ia32cap=0xfcd83209078bffff:0x0 env:~0x200000200000000 | ||
The 'numbers' are in 1000s of bytes per second processed. | ||
type 2 bytes 31 bytes 136 bytes 1024 bytes 8192 bytes 16384 bytes | ||
AES-256-GCM 4630.34k 50358.60k 142015.55k 280143.33k 310561.70k 311596.27k | ||
``` | ||
|
||
</details> | ||
|
||
<details> | ||
<summary>Chacha20-Poly1305</summary> | ||
|
||
``` | ||
PS C:\> openssl speed -elapsed -aead -evp chacha20-poly1305 | ||
You have chosen to measure elapsed time instead of user CPU time. | ||
Doing ChaCha20-Poly1305 ops for 3s on 2 size blocks: 8312139 ChaCha20-Poly1305 ops in 3.00s | ||
Doing ChaCha20-Poly1305 ops for 3s on 31 size blocks: 7801222 ChaCha20-Poly1305 ops in 3.00s | ||
Doing ChaCha20-Poly1305 ops for 3s on 136 size blocks: 5436377 ChaCha20-Poly1305 ops in 3.00s | ||
Doing ChaCha20-Poly1305 ops for 3s on 1024 size blocks: 4182141 ChaCha20-Poly1305 ops in 3.00s | ||
Doing ChaCha20-Poly1305 ops for 3s on 8192 size blocks: 903567 ChaCha20-Poly1305 ops in 3.00s | ||
Doing ChaCha20-Poly1305 ops for 3s on 16384 size blocks: 472556 ChaCha20-Poly1305 ops in 3.00s | ||
version: 3.4.0 | ||
built on: Tue Oct 22 23:27:41 2024 UTC | ||
options: bn(64,64) | ||
compiler: cl /Z7 /Fdossl_static.pdb /Gs0 /GF /Gy /MD /W3 /wd4090 /nologo /O2 -DL_ENDIAN -DOPENSSL_PIC -D"OPENSSL_BUILDING_OPENSSL" -D"OPENSSL_SYS_WIN32" -D"WIN32_LEAN_AND_MEAN" -D"UNICODE" -D"_UNICODE" -D"_CRT_SECURE_NO_DEPRECATE" -D"_WINSOCK_DEPRECATED_NO_WARNINGS" -D"NDEBUG" -D_WINSOCK_DEPRECATED_NO_WARNINGS -D_WIN32_WINNT=0x0502 | ||
CPUINFO: OPENSSL_ia32cap=0xfed8320b078bffff:0x400684219c97a9 | ||
The 'numbers' are in 1000s of bytes per second processed. | ||
type 2 bytes 31 bytes 136 bytes 1024 bytes 8192 bytes 16384 bytes | ||
ChaCha20-Poly1305 5539.58k 80585.77k 246284.90k 1427504.13k 2465696.49k 2580785.83k | ||
``` | ||
|
||
</details> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.