Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

websocket: improve frame parsing #3447

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tsctx
Copy link
Member

@tsctx tsctx commented Aug 12, 2024

Adjust to avoid creating a temporary buffer

@tsctx tsctx requested a review from KhafraDev August 12, 2024 14:10
@KhafraDev
Copy link
Member

I'd prefer if there was a benchmark to measure the change.

@tsctx
Copy link
Member Author

tsctx commented Aug 12, 2024

As an example, the 256Kib receive benchmark is 1.2x faster.

@KhafraDev
Copy link
Member

Benchmarking websockets is hard and there is no benchmark to verify.

@tsctx
Copy link
Member Author

tsctx commented Aug 13, 2024

Benchmarking websockets is hard and there is no benchmark to verify.

It is a simple benchmark using console.time.
For a correct benchmark, it should be a Parser-only benchmark.

@tsctx

This comment was marked as outdated.

@KhafraDev
Copy link
Member

I'd prefer a benchmark that uses WebSocket, not websocket internals. If #3203 could be completed, and then this PR benchmarked against that, I wouldn't have any complaints.

@tsctx tsctx force-pushed the websocket/improve-frame-parsing branch from 22d310a to a6b399a Compare October 15, 2024 13:02
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@tsctx
Copy link
Member Author

tsctx commented Oct 15, 2024

@KhafraDev Would you be able to revisit this? This is the result of the #3203's of benchmarks.

before / after

> $ node ./benchmarks/websocket-benchmark.mjs
(node:11148) [UNDICI-WSS] Warning: WebSocketStream is experimental! Expect it to change at any time.
(Use `node --trace-warnings ...` to show where the warning was created)
undici [binary]: transferred 95.78MiB Bytes/s
undici [string]: transferred 92.98MiB Bytes/s
undici - stream [binary]: transferred 95.93MiB Bytes/s
undici - stream [string]: transferred 97.00MiB Bytes/s
ws [binary]: transferred 125.82MiB Bytes/s
ws [string]: transferred 117.20MiB Bytes/s
> $ node ./benchmarks/websocket-benchmark.mjs
(node:3924) [UNDICI-WSS] Warning: WebSocketStream is experimental! Expect it to change at any time.
(Use `node --trace-warnings ...` to show where the warning was created)
undici [binary]: transferred 113.48MiB Bytes/s
undici [string]: transferred 112.11MiB Bytes/s
undici - stream [binary]: transferred 106.25MiB Bytes/s
undici - stream [string]: transferred 91.41MiB Bytes/s
ws [binary]: transferred 122.96MiB Bytes/s
ws [string]: transferred 114.50MiB Bytes/s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants