Closed retrogradeorbit closed 2 years ago
from linux tcp(7)
man page:
TCP_NODELAY
If set, disable the Nagle algorithm. This means that
segments are always sent as soon as possible, even if
there is only a small amount of data. When not set, data
is buffered until there is a sufficient amount to send
out, thereby avoiding the frequent sending of small
packets, which results in poor utilization of the network.
This option is overridden by TCP_CORK; however, setting
this option forces an explicit flush of pending output,
even if TCP_CORK is currently set.
Ah nice! I should retry the lanterna pod + tetris example with this setting, since it seemed a bit slow at the time!
:+1: Make sure to also turn it on in the pod! https://github.com/babashka/pod-babashka-lanterna/blob/main/src/pod/babashka/lanterna.clj#L167
Oh I see! I tested it with only the updated bb, but the delay was still quite noticeable. I'll also turn it on in the pod :)
I don't know about the tetris game, but the lanterna test script is much faster with it on in the pod. Just gave it a quick patch and compared. Not sure how to get that tetris code to use the pod...
The easiest way is to copy the pod-babashka-lanterna pod to your local directory, because this is where the tetris game expects it to be.
What I did is clone this https://github.com/borkdude/console-tetris/tree/pod-babashka-lanterna locally, check out the branch pod-babashka-lanterna, copy the lanterna pod locally and then run: bb -cp src -m tetris.core
Still seems unreasonably slow :thinking:
Wait. Was using wrong bb version. OK thats heaps better. Actually playable now! :guitar:
When using
:transport :socket
on a pod, setting TCP_NODELAY on both sides (should also be set in the pod) of the connection speeds up calls 100x.Testing with 1449 invoke and responses:
before: "Elapsed time: 127872.209778 msecs" = 88 msecs per round trip.
after: "Elapsed time: 1219.170753 msecs" = 0.84 msecs per round trip