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

Document how to disable TCP_NODELAY (nagle) and enable quickack #159

Open
robsmith11 opened this issue Jul 30, 2020 · 6 comments
Open

Document how to disable TCP_NODELAY (nagle) and enable quickack #159

robsmith11 opened this issue Jul 30, 2020 · 6 comments

Comments

@robsmith11
Copy link

It took a bit of digging for me to figure how to do this, and I would think that many users of websockets would want to be able to adjust the tcp socket options.

For example, for a wss connection:

WebSockets.open("wss://uri") do ws
 Sockets.naggle(ws.socket.bio, false)
 Sockets.quickack(ws.socket.bio, true)
 ...
end
@EricForgy
Copy link
Contributor

That sounds like it would make a great contribution to the docs. PRs are welcome 😊

@hustf
Copy link
Collaborator

hustf commented Jul 31, 2020

I did a fair amount of tweaking for a js user interface/ julia backend, but was not aware of these functions. This package provides some longer printouts of websockets when you use special settings for such tweaking. Also, that optimization process is the reason behind the unfinished or unmaintained benchmark and latency / message size graph sections. I thought it might be interesting to those who are picking a strategy for user interfaces towards a running Julia calculation model: what kind of data to use as interface?

For websockets and Julia, sermingly random hangups additionaly occur due to compilation and gcc. The first can be fixed by sending warm-up messages (ping and pong are not enough). The second requires no memory allocations in your live functions.

The tcp delays and speeds are continously optimized by behind the scenes magic, as I understand it.

@robsmith11
Copy link
Author

I'm building an application that needs consistent low latency, so I'll be doing a lot more testing. Without disabling nagle, small packets weren't getting sent until additional messages were queued.

I'll plan on using PackageCompiler.jl and writing everything in the hot path allocation-free. I may even end up disabling GC.

I'll have to see if I can get the websocket and parsing logic to work in Julia with reusable buffers. Otherwise, I may call C++ for some things.

@hustf
Copy link
Collaborator

hustf commented Jul 31, 2020

That's consistent with what we see in the test. Disabling nagle would decrease latency. The tests originally ran in parallel processes on Julia v0.5 i believe.

You may be aware of the talk(s) @rdeits gave on live robotics controls. If I remember correcty, he got down to zero allocations, but I'm not sure that was actually websockets. Packagecompiler was not available at the time.

To the point of the issue, this package is lagging behind with regards to documentation. Other packages now use Documenter.jl, but settting that up requires some work. At this point, I believe the lowest threshold approach is to make changes to the wiki that Eric put in at one time.

@jvo203
Copy link

jvo203 commented Mar 19, 2024

Just being pedantic here but when you say "disable TCP_NODELAY (nagle)" do you mean "enable TCP_NODELAY (disable Nagle)"? Because disabling TCP_NODELAY literally means enabling the original Nagle algorithm, which is probably not your intention. Just being pedantic!!!

@Moelf
Copy link

Moelf commented May 10, 2024

it really should be the default to set TCP_NODELAY (see https://news.ycombinator.com/item?id=40310896)

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

No branches or pull requests

5 participants