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

获取Serializer和Deserializer时,高并发情况下线程block #1196

Merged
merged 3 commits into from
Jan 11, 2018
Merged

获取Serializer和Deserializer时,高并发情况下线程block #1196

merged 3 commits into from
Jan 11, 2018

Conversation

carryxyh
Copy link
Member

SerializerFactory是从hession中移植过来的类,之前版本的_cachedSerializerMap、_cachedDeserializerMap和_cachedTypeDeserializerMap均为hashmap,获取Serializer(getSerializer方法)和Deserializer时,锁住整个hashmap,锁粒度太大。现在改成ConcurrentHashMap。

hessian 4.0.38中也已经将这两个hashmap替换为ConcurrentHashMap。

@CLAassistant
Copy link

CLAassistant commented Jan 10, 2018

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@codecov-io
Copy link

codecov-io commented Jan 10, 2018

Codecov Report

Merging #1196 into master will decrease coverage by 0.1%.
The diff coverage is 71.42%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1196      +/-   ##
==========================================
- Coverage   27.69%   27.59%   -0.11%     
==========================================
  Files         789      789              
  Lines       41577    41565      -12     
  Branches     8476     8476              
==========================================
- Hits        11515    11468      -47     
- Misses      28019    28053      +34     
- Partials     2043     2044       +1
Impacted Files Coverage Δ
...ibaba/com/caucho/hessian/io/SerializerFactory.java 55% <71.42%> (-1.17%) ⬇️
...ubbo/rpc/protocol/dubbo/ChannelWrappedInvoker.java 41.66% <0%> (-8.34%) ⬇️
...mon/serialize/support/dubbo/GenericDataOutput.java 66.66% <0%> (-7.02%) ⬇️
...om/alibaba/dubbo/rpc/filter/ActiveLimitFilter.java 83.33% <0%> (-5.56%) ⬇️
...mmon/serialize/support/dubbo/GenericDataInput.java 59.45% <0%> (-3.87%) ⬇️
...bo/remoting/transport/netty/NettyCodecAdapter.java 55.22% <0%> (-1.5%) ⬇️

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 f371d78...7291963. Read the comment docs.

@lovepoem
Copy link
Member

@carryxyh Please add some unit test

@carryxyh
Copy link
Member Author

已经添加了相关单元测试。主要是模拟单线程和多线程获取Serializer和Deserializer,保证一个SerializerFactory中,一个class只对应一个Serializer和Deserializer。

@beiwei30 beiwei30 merged commit c2cc20c into apache:master Jan 11, 2018
casnanda added a commit to casnanda/dubbo that referenced this pull request Jan 14, 2018
* 'master' of https://github.com/alibaba/dubbo: (248 commits)
  获取Serializer和Deserializer时,高并发情况下线程block (apache#1196)
  Merge pull request from apache#1170, fix typo of SUFFIXES.
  apache#992 add codecov component (apache#993)
  Merge pull request from apache#1131,  delete empty comments.
  Translate missing content and add apache license
  Add apache license and remove @author comment
  I18N effort for dubbo-common, translate the missing content
  I18N effort for code base, translate the missing content
  I18N effort for dubbo-admin, translate the missing content
  I18N effort for dubbo-cluster, translate the missing content
  I18N effort, translate the missing content
  I18N effort for dubbo-remoting, translate the missing content
  Change default locale from zh to en
  I18N effort for dubbo-admin, xml and UT, apache#1124
  I18N effort for dubbo-admin, apache#1124
  fix typo
  translate comments into english
  translate comments
  fix typo
  change comment to english
  ...

# Conflicts:
#	dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/RoundRobinLoadBalance.java
#	dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/ServiceConfig.java
chickenlj pushed a commit that referenced this pull request Jan 16, 2018
* SerializerFactory 获取Serializer时,锁住整个hashmap,导致整个过程被block

* 单元测试。保证一个class只有一个serializer和deserializer。单线程和多线程测试

* 增加线程数 50 模拟多个线程来获取serializer和deserializer
@chickenlj chickenlj added this to the 2.6.1 milestone Mar 16, 2018
rolandhe pushed a commit to rolandhe/dubbo that referenced this pull request Sep 9, 2019
* SerializerFactory 获取Serializer时,锁住整个hashmap,导致整个过程被block

* 单元测试。保证一个class只有一个serializer和deserializer。单线程和多线程测试

* 增加线程数 50 模拟多个线程来获取serializer和deserializer
rolandhe pushed a commit to rolandhe/dubbo that referenced this pull request Sep 9, 2019
* SerializerFactory 获取Serializer时,锁住整个hashmap,导致整个过程被block

* 单元测试。保证一个class只有一个serializer和deserializer。单线程和多线程测试

* 增加线程数 50 模拟多个线程来获取serializer和deserializer
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