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

TCP网络性能优化思路 #2

Open
c0x0o opened this issue Jul 5, 2019 · 0 comments
Open

TCP网络性能优化思路 #2

c0x0o opened this issue Jul 5, 2019 · 0 comments
Labels
enhancement Performance optimization official Issues raised by official team

Comments

@c0x0o
Copy link
Owner

c0x0o commented Jul 5, 2019

目前TCP模块在小报文的传输性能上不尽如人意。以ping-pong服务为例,由于引入了协程来帮助处理收发工作,协程的换出、唤醒,唤醒条件判断,EventLoop对协程的调度等操作都将以降低网络性能为代价。虽然我个人认为这种开销是提供更高级别代码抽象所必需的,但我们仍然需要使整个框架的性能尽可能接近原生网络操作。

为了解决上述问题,提出了以下几个思路:

  1. EventLoop对象中添加WaitQueue,当一个Service通过pollable对象或其它通知机制由STATUS_HUNG状态变为STATUS_READY时,将自己加入到该WaitQueue中。该优化应该可以显著减少EventLoop在轮询Service对象时产生的开销(尤其是在Service对象数量较大且活跃度不高的情况下)。(已完成,但是在大量连接活跃的情况下效果一般)
  2. 优化TCPConnectionHandleReadHandleWrite的逻辑,减少不必要的循环(次要)
@c0x0o c0x0o added enhancement Performance optimization official Issues raised by official team labels Jul 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Performance optimization official Issues raised by official team
Projects
None yet
Development

No branches or pull requests

1 participant