Comments (9)
不会被”不断唤醒“, 因为有EPOLLONESHOT
from gaio.
因为你readers不为空,会一直Rearm,重现步骤是:启动echo server,客户端发起连接,但是不发任何数据。
from gaio.
因为你readers不为空,会一直Rearm,重现步骤是:启动echo server,客户端发起连接,但是不发任何数据。
仔细看代码
from gaio.
这是我启动echo_server, telnet 连接上去,CPU的占用
from gaio.
看到了,确实有这个问题。
from gaio.
fix了
from gaio.
还有个问题,我注意到你使用了EPOLLONESHOT|EPOLLET方式添加到epoll,但是每次从fd读数据(tryRead函数)并没有保证读干净(一直读到EAGAIN)。比如客户端向服务端发送7K数据并停止,服务端内核buffer中立即收到了7K数据,这时发起一个异步读请求ReadFull 4K数据能返回,但是后面只要客户端不再发数据,因为ET模式的缘故,就再也不会唤醒读了,导致剩余3K数据读不到。
from gaio.
还有个问题,我注意到你使用了EPOLLONESHOT|EPOLLET方式添加到epoll,但是每次从fd读数据(tryRead函数)并没有保证读干净(一直读到EAGAIN)。比如客户端向服务端发送7K数据并停止,服务端内核buffer中立即收到了7K数据,这时发起一个异步读请求ReadFull 4K数据能返回,但是后面只要客户端不再发数据,因为ET模式的缘故,就再也不会唤醒读了,导致剩余3K数据读不到。
不会
from gaio.
除了EPOLLONESHOT确实没法不浪费重复触发并反向传导流控,但是EPOLLONESHOT的syscall更多也确实是浪费性能,我最初只用EPOLLLT没支持EPOLLET,后来增加了支持,但是没支持EPOLLONESHOT,最近也在琢磨可不可以折衷一点,EPOLLET不带EPOLLONESHOT,fd上带个当前state、如果已经可读则不重复派发给应用,标准库似乎就是这种但runtime还自带了调度。
通常情况下交互,EPOLLET的未读完时新数据到来导致重复事件的浪费情况很少,kcptun这种隧道性质的跟普通的业务应用相比确实是特殊场景。
如果是kcptun这种,EPOLLET即使重复派发但应用层仍然根据流控的反向传导来决定要不要读,即使重发派发了其实应该也还好,被反向流控时等待了,系统本来也就不繁忙,所以即使多触发几次事件也不会太影响吞吐
而对于普通应用每个conn其实重复触发的概率很低,所以也不太会影响吞吐
所以要不要考虑下去掉EPOLLONESHOT?去掉的话,真正跑很高量的场景下,省掉的syscall可能会让吞吐好于现在的
from gaio.
Related Issues (19)
- Memory consumption benchmark? HOT 2
- does this support UDP ? HOT 1
- Detach a connection from watcher. HOT 5
- tls support
- does this support UDP also ? HOT 3
- Watcher should not be limited to net.Conn, file descriptor maybe better HOT 1
- 如何获取客户端关闭链接事件
- `go get` error HOT 2
- dara race issue HOT 2
- go 1.17在linux下编译不过
- OOM for 3K websockets HOT 7
- when support tls?
- net.Dial可以用吗? HOT 1
- 关于 loop 函数中 copy(pending, w.pending) 的疑问 HOT 1
- epoll边缘触发数据未读完的问题 HOT 3
- 如何利用多核呢 HOT 1
- 为什么不支持windows啊- - HOT 2
- 超时处理问题
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gaio.