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

send with array of buffers #837

Closed
ronag opened this issue Nov 20, 2022 · 3 comments
Closed

send with array of buffers #837

ronag opened this issue Nov 20, 2022 · 3 comments
Labels
wontfix This will not be worked on

Comments

@ronag
Copy link

ronag commented Nov 20, 2022

Currently, I'm doing this:

ws.cork(() => {
  for (const data of buffer.splice(0)) (
    ws.send(data)
  }
})

Which does a lot of js->cpp calls. Would it make sense to be able to do the following?

ws.cork(() => {
  ws.send(buffer.splice(0))
})
@uNetworkingAB
Copy link
Contributor

#528 #679 are similar posts.

I'm not interested in micro optimizing some specific use case - JavaScript is a script and if you plan your data flow you can get decent IO perf with uWS. But the shortcomings of this script should not result in this library adding tons of hacks to avoid JavaScript behavior. After all you are scripting.

If these micro overheads are a problem then use C++, but these are not really low hanging fruits there are way way heavier problems in Node.js itself (we lose 70% perf in node.js 14 because of mistakes in nodejs)

@uNetworkingAB
Copy link
Contributor

All functions like writeStatus, writeHeader, write, send, should ideally be V8 fast calls but until Node.js camp exposes that API I cannot do anything about it. But even now, the overhead of calling into C++ is negligible compared to the overhead of calling into JS with node::MakeCallback. It's like day and night of a difference. You lose a drip going into C++ but you lose an entire ocean going into JS.

@uNetworkingAB uNetworkingAB added the wontfix This will not be worked on label Nov 20, 2022
@ronag
Copy link
Author

ronag commented Nov 22, 2022

@uNetworkingAB Trying to raise the MakeCallback issue again. nodejs/performance#24

Do you have any benchmark script that can be used for reference in the discussion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants