You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "CalvinKirs (GitHub)" <gi...@apache.org> on 2019/02/26 02:57:56 UTC
[GitHub] [incubator-dubbo] CalvinKirs opened pull request #3567: a
more elegant way
## What is the purpose of the change
a more elegant way,higher efficiency。
## Brief changelog
no
## Verifying this change
no
Follow this checklist to help us incorporate your contribution quickly and easily:
run the test case
[ Full content available at: https://github.com/apache/incubator-dubbo/pull/3567 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] CalvinKirs commented on issue #3567: a
more elegant way
Posted by "CalvinKirs (GitHub)" <gi...@apache.org>.
> Can u give some benchmark to verify that your way is better performance?
我做过一些测试,从一到百万,用该种方式的效率是原来方式的几十倍
[ Full content available at: https://github.com/apache/incubator-dubbo/pull/3567 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] codecov-io commented on issue #3567: a
more elegant way
Posted by "codecov-io (GitHub)" <gi...@apache.org>.
# [Codecov](https://codecov.io/gh/apache/incubator-dubbo/pull/3567?src=pr&el=h1) Report
> Merging [#3567](https://codecov.io/gh/apache/incubator-dubbo/pull/3567?src=pr&el=desc) into [master](https://codecov.io/gh/apache/incubator-dubbo/commit/ade0cd70243416fadb0a4a52ad4e8df191738f92?src=pr&el=desc) will **increase** coverage by `0.06%`.
> The diff coverage is `100%`.
[](https://codecov.io/gh/apache/incubator-dubbo/pull/3567?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #3567 +/- ##
============================================
+ Coverage 63.98% 64.05% +0.06%
Complexity 71 71
============================================
Files 664 664
Lines 28629 28632 +3
Branches 4753 4767 +14
============================================
+ Hits 18319 18339 +20
+ Misses 8079 8069 -10
+ Partials 2231 2224 -7
```
| [Impacted Files](https://codecov.io/gh/apache/incubator-dubbo/pull/3567?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| [...rg/apache/dubbo/common/timer/HashedWheelTimer.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3567/diff?src=pr&el=tree#diff-ZHViYm8tY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9jb21tb24vdGltZXIvSGFzaGVkV2hlZWxUaW1lci5qYXZh) | `58.62% <100%> (+0.78%)` | `0 <0> (ø)` | :arrow_down: |
| [...e/dubbo/remoting/transport/netty/NettyChannel.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3567/diff?src=pr&el=tree#diff-ZHViYm8tcmVtb3RpbmcvZHViYm8tcmVtb3RpbmctbmV0dHkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2R1YmJvL3JlbW90aW5nL3RyYW5zcG9ydC9uZXR0eS9OZXR0eUNoYW5uZWwuamF2YQ==) | `57.64% <0%> (-3.53%)` | `0% <0%> (ø)` | |
| [...bo/rpc/cluster/support/FailbackClusterInvoker.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3567/diff?src=pr&el=tree#diff-ZHViYm8tY2x1c3Rlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZHViYm8vcnBjL2NsdXN0ZXIvc3VwcG9ydC9GYWlsYmFja0NsdXN0ZXJJbnZva2VyLmphdmE=) | `67.21% <0%> (-3.28%)` | `0% <0%> (ø)` | |
| [.../exchange/support/header/HeaderExchangeServer.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3567/diff?src=pr&el=tree#diff-ZHViYm8tcmVtb3RpbmcvZHViYm8tcmVtb3RpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9yZW1vdGluZy9leGNoYW5nZS9zdXBwb3J0L2hlYWRlci9IZWFkZXJFeGNoYW5nZVNlcnZlci5qYXZh) | `65.09% <0%> (-1.89%)` | `0% <0%> (ø)` | |
| [...che/dubbo/common/compiler/support/JdkCompiler.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3567/diff?src=pr&el=tree#diff-ZHViYm8tY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9jb21tb24vY29tcGlsZXIvc3VwcG9ydC9KZGtDb21waWxlci5qYXZh) | `64.54% <0%> (ø)` | `0% <0%> (ø)` | :arrow_down: |
| [.../apache/dubbo/remoting/transport/AbstractPeer.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3567/diff?src=pr&el=tree#diff-ZHViYm8tcmVtb3RpbmcvZHViYm8tcmVtb3RpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9yZW1vdGluZy90cmFuc3BvcnQvQWJzdHJhY3RQZWVyLmphdmE=) | `63.04% <0%> (ø)` | `0% <0%> (ø)` | :arrow_down: |
| [...ache/dubbo/remoting/transport/AbstractChannel.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3567/diff?src=pr&el=tree#diff-ZHViYm8tcmVtb3RpbmcvZHViYm8tcmVtb3RpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9yZW1vdGluZy90cmFuc3BvcnQvQWJzdHJhY3RDaGFubmVsLmphdmE=) | `75% <0%> (ø)` | `0% <0%> (ø)` | :arrow_down: |
| [...org/apache/dubbo/registry/redis/RedisRegistry.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3567/diff?src=pr&el=tree#diff-ZHViYm8tcmVnaXN0cnkvZHViYm8tcmVnaXN0cnktcmVkaXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2R1YmJvL3JlZ2lzdHJ5L3JlZGlzL1JlZGlzUmVnaXN0cnkuamF2YQ==) | `39.03% <0%> (+0.28%)` | `0% <0%> (ø)` | :arrow_down: |
| [...org/apache/dubbo/config/context/ConfigManager.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3567/diff?src=pr&el=tree#diff-ZHViYm8tY29uZmlnL2R1YmJvLWNvbmZpZy1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2R1YmJvL2NvbmZpZy9jb250ZXh0L0NvbmZpZ01hbmFnZXIuamF2YQ==) | `65.07% <0%> (+0.79%)` | `0% <0%> (ø)` | :arrow_down: |
| ... and [10 more](https://codecov.io/gh/apache/incubator-dubbo/pull/3567/diff?src=pr&el=tree-more) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-dubbo/pull/3567?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/incubator-dubbo/pull/3567?src=pr&el=footer). Last update [ade0cd7...ebeab5d](https://codecov.io/gh/apache/incubator-dubbo/pull/3567?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
[ Full content available at: https://github.com/apache/incubator-dubbo/pull/3567 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] CalvinKirs commented on issue #3567: a
more elegant way
Posted by "CalvinKirs (GitHub)" <gi...@apache.org>.
static final int newNormalizeTicksPerWheel(int ticksPerWheel) {
int n = ticksPerWheel;
n |= n >>> 1;
n |= n >>> 2;
n |= n >>> 4;
n |= n >>> 8;
n |= n >>> 16;
return n + 1;
}
public static void main(String[] args) {
Long startTime = System.currentTimeMillis();
for (int n = 1; n < 10000000; n++) {
oldNormalizeTicksPerWheel(n);
}
Long endTimeOne = System.currentTimeMillis();
for (int n = 1; n < 10000000; n++) {
newNormalizeTicksPerWheel(n);
}
System.out.println(endTimeOne - startTime);
System.out.println(System.currentTimeMillis() - endTimeOne);
}
private static int oldNormalizeTicksPerWheel(int ticksPerWheel) {
int normalizedTicksPerWheel = 1;
while (normalizedTicksPerWheel < ticksPerWheel) {
normalizedTicksPerWheel <<= 1;
}
return normalizedTicksPerWheel;
}
[ Full content available at: https://github.com/apache/incubator-dubbo/pull/3567 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] CalvinKirs commented on issue #3567: a
more elegant way
Posted by "CalvinKirs (GitHub)" <gi...@apache.org>.
>From hashmap
[ Full content available at: https://github.com/apache/incubator-dubbo/pull/3567 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] carryxyh commented on issue #3567: a more
elegant way
Posted by "carryxyh (GitHub)" <gi...@apache.org>.
Can u give some benchmark to verify that your way is better performance?
[ Full content available at: https://github.com/apache/incubator-dubbo/pull/3567 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] carryxyh commented on issue #3567: a more
elegant way
Posted by "carryxyh (GitHub)" <gi...@apache.org>.
Attach your code will be better.
Maybe a little ut in org.apache.dubbo.common.timer.HashedWheelTimerTest is enough.
[ Full content available at: https://github.com/apache/incubator-dubbo/pull/3567 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org