Skip to content

[Dubb - epoll ] Support epoll - #2738

Closed
zonghaishang wants to merge 12 commits into
apache:masterfrom
zonghaishang:support_epoll
Closed

zonghaishang wants to merge 12 commits into
apache:masterfrom
zonghaishang:support_epoll

Conversation

@zonghaishang

Copy link
Copy Markdown
Member

What is the purpose of the change

support epoll for dubbo, refer: #2737

Brief changelog

  1. consumerConfig, providerConfig, dubbo.xsd
  2. AbstractSupport, NettySupport, NettyServer, NettyClient

Verifying this change

ci passed & benchmark test passed.

benchmark: https://github.com/zonghaishang/dubbo-benchmark/tree/epoll_benchmark

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a GITHUB_issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a GITHUB issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [Dubbo-XXX] Fix UnknownException when host config not exist #XXX. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn clean install -DskipTests & mvn clean test-compile failsafe:integration-test to make sure unit-test and integration-test pass.
  • If this contribution is large, please follow the Software Donation Guide.

@codecov-io

codecov-io commented Nov 5, 2018 •

Copy link
Copy Markdown

Codecov Report

Merging #2738 into master will decrease coverage by 0.12%.
The diff coverage is 70.12%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2738      +/-   ##
==========================================
- Coverage   64.09%   63.96%   -0.13%     
==========================================
  Files         584      589       +5     
  Lines       26059    26129      +70     
  Branches     4562     4569       +7     
==========================================
+ Hits        16702    16714      +12     
- Misses       7184     7229      +45     
- Partials     2173     2186      +13
Impacted Files Coverage Δ
...ing/transport/netty4/NettyBackedChannelBuffer.java 19.04% <ø> (ø) ⬆️
...c/main/java/org/apache/dubbo/common/Constants.java 88.88% <ø> (ø) ⬆️
...e/dubbo/remoting/transport/netty4/NettyServer.java 75.8% <100%> (+0.39%) ⬆️
...bbo/remoting/transport/netty4/NativeTransport.java 100% <100%> (ø)
...n/java/org/apache/dubbo/config/ConsumerConfig.java 86.2% <33.33%> (-6.11%) ⬇️
...n/java/org/apache/dubbo/config/ProviderConfig.java 93.75% <33.33%> (-1.95%) ⬇️
...o/remoting/transport/netty4/TransporterConfig.java 43.75% <43.75%> (ø)
...oting/transport/netty4/NativeTransportFactory.java 50% <50%> (ø)
...o/remoting/transport/netty4/AbstractTransport.java 71.42% <71.42%> (ø)
.../dubbo/remoting/transport/netty4/ConfigOption.java 77.77% <77.77%> (ø)
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 31de870...50bb3c8. Read the comment docs.

@carryxyh carryxyh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外一个问题,epoll属性会不会透传?
按照目前的方式应该是会的,通过url会从provider透传到consumer,从而影响到consumer的epoll。
实际上感觉不透传好一些吧?

this.epoll = isLinux() && url.getParameter(Constants.EPOLL_ENABLE, false);
}

public NioEventLoopGroup nioEventLoopGroup(ThreadFactory threadFactory) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

abstractsupport里不要放这种代码比较好吧?
nioEventLoopGroup方法其实已经具体到netty了,是不是把它放到实现里比较好。

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

epoll作为基类封装起来问题不大

@zonghaishang

zonghaishang commented Nov 6, 2018 •

Copy link
Copy Markdown
Member Author

针对:按照目前的方式应该是会的,通过url会从provider透传到consumer,从而影响到consumer的epoll。
实际上感觉不透传好一些吧?

epoll server支持 epoll 和 非epoll调用过来,透传给client, 如果client自动知道server支持epoll,自动适配是合适的。

}
this.url = url;
this.nThreads = url.getPositiveParameter(Constants.IO_THREADS_KEY, Constants.DEFAULT_IO_THREADS);
this.epoll = isLinux() && url.getParameter(Constants.EPOLL_ENABLE, false);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linux system doesn't mean it support epoll. we also need check major version.
Or we can use io.netty.channel.epoll.Epoll, it has a method isAvailable

@zonghaishang zonghaishang Nov 7, 2018 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@htynkn nice, fixed it.

@beiwei30

beiwei30 commented Nov 8, 2018

Copy link
Copy Markdown
Member

没仔细看,几个建议:

  • epoll 打开与否目前只和 netty4 绑定,合理的做法是和 protocol 上的 transporter 绑定。或者在应用级别来控制(虽然现在只有 netty4 才支持)。也就是说没有必要在 provider, consumer, protocol 上都有是否支持 epoll 的判断
  • epoll 只是对 linux 平台上 native transport 的支持而已,更合理的做法是把 AbstractSupport 和 NettySupport 合并成 NativeTransportFactory,用来根据配置和平台自动返回对应的 SocketChannel 和 EventLoopGroup 的实例,当然出错情况下自动 fallbak 回 nio

综上所述,看起来 Transporter 应该有一个 TransporterConfig,或者干脆在 app 级别上定义。如果想不清楚,暂时通过 system properties 指定也是可以的。Native Transport 的支持需要考虑全平台,而不是只有 linux 上的 epoll,做成 factory 模式,出错 fallback 到 nio


I have a couple of suggestions after take a glance at the implementation:

  • Right now, epoll support is tightly coupled with transport netty4, which I think it is fine, but from the perspective of its configuration, I believe more reasonable place for this configuration is transporter, or in my own opinion this configuration for whether enable native transport or now is global configuration, and should be applied to application level, even though currently we will only have its support for linux on netty4. It is unnecessary and unreasonable to have the individual configuration for enabling epoll on different levels like provider, consumer, and protocol.
  • Right now the implementation focus on epoll support only, we should consider more. Besides epoll on linux, we should also support kqueue on Mac/BSD, see https://netty.io/wiki/native-transports.html for more details. What I suggest is to implement a NativeTransportFactory by combining and enhancing the code in AbstractSupport and NettySupport together to produce the appropriate instances for SocketChannel and EventLoopGroup according to the platforms and the configurations the current application is running on. Of course, this factory should fallback to return the nio instances if anything goes wrong.

In summary, we should either define 'native-transporter' on ApplicationConfig or TransporterConfig (not introduced yet). It is also reasonable to introduce it with a system property if we cannot make the decision now. For native transport support, we should consider not only epoll on linux, but also others.

@zonghaishang

zonghaishang commented Nov 8, 2018 •

Copy link
Copy Markdown
Member Author

epoll 打开与否目前只和 netty4 绑定,合理的做法是和 protocol 上的 transporter 绑定。或者在应用级别来控制(虽然现在只有 netty4 才支持)。也就是说没有必要在 provider, consumer, protocol 上都有是否支持 epoll 的判断

嗯,考虑了下移除protocol控制更合适,我会修复掉

@lexburner

Copy link
Copy Markdown
Contributor

+1, 之前测试过 Netty 支持的 native epoll, benchmark 的时候感触挺深,使用 NioSocketChannel 最高 qps 5600 ,替换成 EpollSocketChannel 之后 6300 qps,提升显著。但局限也是有的,1. 不兼容低版本 netty 2. 只在部分 linux 平台支持。
同意 @beiwei30 的建议,不需要在 dubbo 层面暴露 epoll 开关。

@beiwei30

beiwei30 commented Dec 6, 2018

Copy link
Copy Markdown
Member

any further update on this pull request @zonghaishang

@zonghaishang zonghaishang self-assigned this Dec 7, 2018
@zonghaishang

Copy link
Copy Markdown
Member Author

Recently dealing with work, this feature will be completed by this week.

@lexburner

lexburner commented Dec 10, 2018 via email

Copy link
Copy Markdown
Contributor

@zonghaishang

Copy link
Copy Markdown
Member Author

@lexburner please provide test code, :-)

@beiwei30

Copy link
Copy Markdown
Member

any further update on this pull request @zonghaishang

@zonghaishang

Copy link
Copy Markdown
Member Author

@beiwei30 I will modify it again as suggested by the code review.

@lexburner

lexburner commented Dec 12, 2018 via email

Copy link
Copy Markdown
Contributor

@apache apache deleted a comment from dubbo-bot Jan 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants