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

[ISSUE #10159]修改mapperProxy单例 #10162

Merged
merged 1 commit into from
Mar 28, 2023
Merged

Conversation

985492783
Copy link
Contributor

fix #10159

@codecov-commenter
Copy link

Codecov Report

Merging #10162 (9bb12bd) into develop (d291f24) will increase coverage by 0.13%.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##             develop   #10162      +/-   ##
=============================================
+ Coverage      51.67%   51.81%   +0.13%     
- Complexity      5077     5081       +4     
=============================================
  Files            873      873              
  Lines          27731    27731              
  Branches        3071     3071              
=============================================
+ Hits           14331    14369      +38     
+ Misses         12073    12037      -36     
+ Partials        1327     1325       -2     

see 6 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

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

@varyuan
Copy link
Contributor

varyuan commented Mar 22, 2023

为什么不用ConcurrentHashMap, 而是用hashmap+lock

@985492783
Copy link
Contributor Author

为什么不用ConcurrentHashMap, 而是用hashmap+lock

用ConcurrentHashMap读写确实没问题,但是在实例对象前一样要对ConcurrentHashMap加锁才能保证实例对象的原子性,所以采用读写锁,但我更想饿汉式加载,就不会存在线程安全的问题了

Copy link
Collaborator

@KomachiSion KomachiSion left a comment

Choose a reason for hiding this comment

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

写锁可以理解, 读锁是不是没有必要?

@985492783
Copy link
Contributor Author

写锁可以理解, 读锁是不是没有必要?

在用spi加载mapper的时候同时创建mapperProxy可以吗,因为预热完就全是读操作了,加锁还是会影响性能,读锁是因为并发读写hashmap如果发生扩容可能会出现读空的情况
image

@985492783 985492783 requested a review from KomachiSion March 24, 2023 06:27
@KomachiSion
Copy link
Collaborator

你的意思是,在loadInitial的时候加载完缓存? 也可以, 目前这个开关是动态的吗? 需要重启吗?

@985492783
Copy link
Contributor Author

你的意思是,在loadInitial的时候加载完缓存? 也可以, 目前这个开关是动态的吗? 需要重启吗?

重新看了下,还是坚持原本的改法了,开关有想法做成动态开关暂时不改这个

@KomachiSion KomachiSion merged commit 953fa9e into alibaba:develop Mar 28, 2023
@KomachiSion KomachiSion added kind/enhancement Category issues or prs related to enhancement. plugin labels Mar 28, 2023
@KomachiSion KomachiSion added this to the 2.3.0 milestone Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Category issues or prs related to enhancement. plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

每次调用findMapper方法都会重新创建一个MapperProxy对象
4 participants