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

optimize: opt codes related to Map and List #3134

Merged
merged 35 commits into from
Oct 17, 2020

Conversation

wangliang181230
Copy link
Contributor

@wangliang181230 wangliang181230 commented Sep 21, 2020

Ⅰ. Describe what this PR did

optimize: opt codes related to Map and List.
优化MapList相关的代码(因为有人吐槽阿里(seata)的开发人员基础差,orz)

优化后的效果:

  1. 可以减少一些性能损耗和不必要的new实例化内存开销。
  2. 代码更加简洁易读。
  3. 部分代码段使用了MapcomputeIfAbsent方法,保证了操作原子性,减少了并发下的重复初始化操作。

Ⅱ. Does this pull request fix one issue?

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@codecov-commenter
Copy link

codecov-commenter commented Sep 21, 2020

Codecov Report

Merging #3134 into develop will increase coverage by 0.03%.
The diff coverage is 51.54%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #3134      +/-   ##
=============================================
+ Coverage      50.45%   50.48%   +0.03%     
- Complexity      3108     3134      +26     
=============================================
  Files            593      593              
  Lines          19571    19512      -59     
  Branches        2427     2413      -14     
=============================================
- Hits            9874     9851      -23     
+ Misses          8702     8682      -20     
+ Partials         995      979      -16     
Impacted Files Coverage Δ Complexity Δ
...main/java/io/seata/common/holder/ObjectHolder.java 0.00% <ø> (ø) 0.00 <0.00> (ø)
...rc/main/java/io/seata/common/util/StringUtils.java 14.04% <0.00%> (-0.18%) 10.00 <0.00> (ø)
...va/io/seata/core/compressor/CompressorFactory.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...re/src/main/java/io/seata/core/rpc/RpcContext.java 40.54% <0.00%> (ø) 21.00 <0.00> (ø)
...ta/core/rpc/netty/AbstractNettyRemotingClient.java 17.91% <0.00%> (+0.17%) 8.00 <0.00> (ø)
...n/java/io/seata/core/rpc/netty/ChannelManager.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
.../io/seata/core/rpc/netty/v1/HeadMapSerializer.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...ery/registry/consul/ConsulRegistryServiceImpl.java 0.99% <0.00%> (ø) 1.00 <0.00> (ø)
...covery/registry/etcd3/EtcdRegistryServiceImpl.java 11.62% <0.00%> (ø) 3.00 <0.00> (ø)
.../main/java/io/seata/rm/datasource/AsyncWorker.java 15.00% <0.00%> (ø) 5.00 <0.00> (ø)
... and 42 more

@wangliang181230 wangliang181230 changed the title optimize: opt map related codes optimize: opt codes related to the map Sep 21, 2020
@wangliang181230 wangliang181230 changed the title optimize: opt codes related to the map optimize: opt codes related to the Map Sep 21, 2020
@wangliang181230 wangliang181230 changed the title optimize: opt codes related to the Map optimize: opt codes related to Map and List Sep 22, 2020
Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

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

computeIfAbsent can guarantee atomic?

@wangliang181230
Copy link
Contributor Author

computeIfAbsent can guarantee atomic?

If the Map is thread safe, it can guarantee atomic.

Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

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

LGTM

…-map-code

# Conflicts:
#	spring/src/main/java/io/seata/spring/annotation/datasource/DataSourceProxyHolder.java
@codecov-io
Copy link

codecov-io commented Oct 10, 2020

Codecov Report

Merging #3134 into develop will increase coverage by 0.05%.
The diff coverage is 54.28%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #3134      +/-   ##
=============================================
+ Coverage      50.53%   50.58%   +0.05%     
- Complexity      3144     3161      +17     
=============================================
  Files            598      598              
  Lines          19774    19698      -76     
  Branches        2467     2441      -26     
=============================================
- Hits            9993     9965      -28     
+ Misses          8779     8745      -34     
+ Partials        1002      988      -14     
Impacted Files Coverage Δ Complexity Δ
...main/java/io/seata/common/holder/ObjectHolder.java 0.00% <ø> (ø) 0.00 <0.00> (ø)
...rc/main/java/io/seata/common/util/StringUtils.java 15.94% <0.00%> (+1.54%) 7.00 <0.00> (-1.00) ⬆️
...va/io/seata/core/compressor/CompressorFactory.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...re/src/main/java/io/seata/core/rpc/RpcContext.java 40.54% <0.00%> (ø) 21.00 <0.00> (ø)
...n/java/io/seata/core/rpc/netty/ChannelManager.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
.../io/seata/core/rpc/netty/v1/HeadMapSerializer.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...ery/registry/consul/ConsulRegistryServiceImpl.java 0.99% <0.00%> (ø) 1.00 <0.00> (ø)
...covery/registry/etcd3/EtcdRegistryServiceImpl.java 11.62% <0.00%> (ø) 3.00 <0.00> (ø)
.../main/java/io/seata/rm/datasource/AsyncWorker.java 15.00% <0.00%> (ø) 5.00 <0.00> (ø)
...ata/saga/proctrl/eventing/impl/DirectEventBus.java 81.48% <0.00%> (ø) 7.00 <0.00> (ø)
... and 45 more

Copy link
Contributor

@niaoshuai niaoshuai left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@funky-eyes funky-eyes left a comment

Choose a reason for hiding this comment

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

LGTM

@funky-eyes funky-eyes merged commit ab7af77 into apache:develop Oct 17, 2020
@wangliang181230 wangliang181230 deleted the optimize-map-code branch October 17, 2020 11:56
@wangliang181230 wangliang181230 added this to the 1.4.0 milestone Oct 17, 2020
l81893521 pushed a commit to l81893521/seata that referenced this pull request Oct 22, 2020
hicf pushed a commit to hicf/seata that referenced this pull request Nov 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants