Closed limpo1989 closed 1 month ago
OnData usually handles parsing, when we got a frame/message in OnData, we handle the frame/message async in another goroutine, which may not finish writing when OnData for next fd is called in the eventloop.
when:
The benchmark results are not different too much, and can not prove the promotion enough. One more thing is, in the real scenarios over the public internet, TCP windows size communication is slower than in the local test env.
In LT mode, if there is no writeable event at present, it does not mean that the socket cannot be written, because the write event registered this time actually needs to wait until the next round of epoll-wait to be triggered.
Perhaps this change will improve intranet services, such as the rpc framework serving intranets. 🤣
In LT mode, if there is no writeable event at present, it does not mean that the socket cannot be written
No matter which epoll mod, It may be writable at the next nano when the epoll_wait returns and before we check the event type, but for most of the time, if there's no write event, it means not writable at this moment. If we don't do flush according to the write event, then we don't need to check the write event and the kernal doesn't need to provide the write event anymore, because the fd maybe writable at any moment. :joy:
When data reading occurs, there is a high probability of data writeback generated in the
OnData
. At this time, it is not necessary to wait for the registration write event callback to immediately perform the write operation, which can improve the performance of sending data.benchmark use https://github.com/lesismal/go-websocket-benchmark
BEFORE
AFTER