WebSockets.jl
WebSockets.jl copied to clipboard
Document how to disable TCP_NODELAY (nagle) and enable quickack
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
That sounds like it would make a great contribution to the docs. PRs are welcome 😊
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.
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.
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.
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!!!
it really should be the default to set TCP_NODELAY
(see https://news.ycombinator.com/item?id=40310896)