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

perf(ext/node): native vectored write for server streams #19752

Merged
merged 5 commits into from
Jul 7, 2023

Conversation

littledivy
Copy link
Member

@littledivy littledivy commented Jul 7, 2023

# main
$ ./load_test 10 0.0.0.0 8080 0 0
Using message size of 20 bytes
Running benchmark now...
Msg/sec: 106182.250000
Msg/sec: 110279.750000
^C

# this PR
$ ./load_test 10 0.0.0.0 8080 0 0
Using message size of 20 bytes
Running benchmark now...
Msg/sec: 131632.250000
Msg/sec: 134754.250000
^C

@littledivy littledivy changed the title perf(ext/node): native write vectored for server streams perf(ext/node): native vectored write for server streams Jul 7, 2023
@littledivy littledivy marked this pull request as ready for review July 7, 2023 08:25
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, but I want more eyes on this. Pinging @mmastrac for additional review.

@bartlomieju bartlomieju requested a review from mmastrac July 7, 2023 14:23
if (typeof chunks[0] === "string") chunks[0] = Buffer.from(chunks[0]);
if (typeof chunks[1] === "string") chunks[1] = Buffer.from(chunks[1]);

ops.op_raw_write_vectored(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this path called with chunks.length == 1 anywhere? There may be an opportunity to optimize for N <= M instead of N == 2.

Copy link
Member Author

Choose a reason for hiding this comment

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

chunks.length == 1 should be using write instead of writev

buf1: JsBuffer,
buf2: JsBuffer,
) -> Result<usize, AnyError> {
let resource: Rc<UpgradeStream> =
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is not an UpgradeStream, it should probably fall back to the standard write methods. I don't think we should assume that any two-chunk write is a websocket write.

Copy link
Member Author

Choose a reason for hiding this comment

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

In JS, All TCPSERVERWRAP provider type resources are an UpgradeStream so this does not need a fallback.

Copy link
Contributor

@mmastrac mmastrac left a comment

Choose a reason for hiding this comment

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

LGTM. Let's land for now and work on vectorizing resources

@littledivy littledivy merged commit e4870d8 into denoland:main Jul 7, 2023
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.

5 participants