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

improve isWindows method in HashedWheelTimer #6845

Merged
merged 2 commits into from Oct 30, 2020
Merged

Conversation

zx844174097
Copy link

@zx844174097 zx844174097 commented Oct 28, 2020

Memory usage is too high。frequently GC

发现所有分支皆有此问题,则提交到主分支

#6820
#6808

bug 所在文件 https://github.com/apache/dubbo/blob/master/dubbo-common/src/main/java/org/apache/dubbo/common/timer/HashedWheelTimer.java

出现问题的方法:
private boolean isWindows() { return System.getProperty("os.name", "").toLowerCase(Locale.US).contains("win"); }
问题产生原因:
1.waitForNextTick() 中无限调用 isWindows();

2.toLowerCase(Locale.US) 将急速产生 char[] 对象。导致内存占用过高。

解决方案:
` private static boolean isWindows = System.getProperty("os.name", "").toLowerCase(Locale.US).contains("win");

private boolean isWindows() {
return isWindows;
}`

close #6820

zx844174097 and others added 2 commits October 28, 2020 20:00
+ add final
+ rename to IS_OS_WINDOWS
@htynkn
Copy link
Member

htynkn commented Oct 30, 2020

this change makes sense to me and will merge soon when CI pass.

Another thing is current way to check OS maybe not good enough. there are many utils can do similar work:

Maybe this is something we can improve in the future

@htynkn htynkn self-assigned this Oct 30, 2020
@htynkn htynkn changed the title Memory usage is too high。frequently GC improve isWindows method in HashedWheelTimer Oct 30, 2020
@codecov-io
Copy link

codecov-io commented Oct 30, 2020

Codecov Report

Merging #6845 into master will decrease coverage by 0.14%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #6845      +/-   ##
============================================
- Coverage     59.15%   59.00%   -0.15%     
+ Complexity      510      506       -4     
============================================
  Files          1028     1028              
  Lines         41534    41535       +1     
  Branches       6041     6041              
============================================
- Hits          24570    24509      -61     
- Misses        14194    14244      +50     
- Partials       2770     2782      +12     
Impacted Files Coverage Δ Complexity Δ
...rg/apache/dubbo/common/timer/HashedWheelTimer.java 62.88% <100.00%> (-0.57%) 0.00 <0.00> (ø)
...rg/apache/dubbo/remoting/utils/PayloadDropper.java 15.38% <0.00%> (-30.77%) 0.00% <0.00%> (ø%)
...ng/transport/dispatcher/all/AllChannelHandler.java 62.06% <0.00%> (-13.80%) 0.00% <0.00%> (ø%)
...he/dubbo/common/threadpool/ThreadlessExecutor.java 52.17% <0.00%> (-10.87%) 0.00% <0.00%> (ø%)
.../apache/dubbo/rpc/protocol/AsyncToSyncInvoker.java 62.06% <0.00%> (-10.35%) 0.00% <0.00%> (ø%)
...e/dubbo/remoting/transport/netty/NettyChannel.java 52.27% <0.00%> (-7.96%) 19.00% <0.00%> (-2.00%)
.../registry/multicast/MulticastServiceDiscovery.java 23.07% <0.00%> (-7.70%) 0.00% <0.00%> (ø%)
.../org/apache/dubbo/remoting/ExecutionException.java 15.78% <0.00%> (-5.27%) 0.00% <0.00%> (ø%)
...mmon/threadpool/support/AbortPolicyWithReport.java 85.00% <0.00%> (-5.00%) 0.00% <0.00%> (ø%)
.../apache/dubbo/remoting/transport/AbstractPeer.java 58.69% <0.00%> (-4.35%) 0.00% <0.00%> (ø%)
... and 12 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 4a8da59...f32930d. Read the comment docs.

@htynkn htynkn merged commit c0a205f into apache:master Oct 30, 2020
@htynkn
Copy link
Member

htynkn commented Oct 30, 2020

thanks for your contribution :)

LeeGuoPing added a commit to LeeGuoPing/dubbo that referenced this pull request Nov 3, 2020
improve isWindows method in HashedWheelTimer (apache#6845)
chickenlj pushed a commit to chickenlj/incubator-dubbo that referenced this pull request Nov 25, 2020
AlbumenJ added a commit to AlbumenJ/dubbo that referenced this pull request May 26, 2021
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.

HashedWheelTimer 内存占用过高bug (dubbo 2.7.8)
3 participants