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

syncx(feat): 添加具有最大申请次数限制的Pool #233

Merged
merged 5 commits into from
Dec 25, 2023

Conversation

longyue0521
Copy link
Collaborator

通过控制一段时间内Pool的最大申请次数(可串行、可并行)来间接控制住Pool的最大使用量

Signed-off-by: longyue0521 <longyueli0521@gmail.com>
Signed-off-by: longyue0521 <longyueli0521@gmail.com>
Copy link

codecov bot commented Dec 17, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (45c4365) 95.91% compared to head (d1c6845) 95.90%.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #233      +/-   ##
==========================================
- Coverage   95.91%   95.90%   -0.01%     
==========================================
  Files          60       61       +1     
  Lines        3233     3250      +17     
==========================================
+ Hits         3101     3117      +16     
- Misses        102      104       +2     
+ Partials       30       29       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: longyue0521 <longyueli0521@gmail.com>
@longyue0521 longyue0521 requested a review from flycash December 17, 2023 14:00
Signed-off-by: longyue0521 <longyueli0521@gmail.com>
Copy link
Contributor

@flycash flycash left a comment

Choose a reason for hiding this comment

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

这个结构的使用场景我有点不太明白。因为从理论上来说,我为啥要限制这个使用次数?我需要的时候我就申请,我不需要就算了。

@longyue0521
Copy link
Collaborator Author

这个结构的使用场景我有点不太明白。因为从理论上来说,我为啥要限制这个使用次数?我需要的时候我就申请,我不需要就算了。

@flycash

之前提到的“一个用户请求,需要申请1MB缓冲区完成业务,看起来合理、问题也不大. 但是一段时间内大量并发用户申请的缓冲区的总量可能占用大量内存,从而影响到同一机器内的其他业务“ 所以需要控制住Pool的最大总内存占用量, 因为Pool中的对象都是通过new方法获得的,可以认为每个对象占用内存大致相等,那么控制住一段时间内的申请次数就相当于间接控制住Pool的最大总内存占用量.

syncx/limit_pool.go Show resolved Hide resolved
syncx/limit_pool.go Outdated Show resolved Hide resolved
Signed-off-by: longyue0521 <longyueli0521@gmail.com>
@longyue0521 longyue0521 requested a review from flycash December 25, 2023 02:17
@flycash flycash merged commit 985e68e into ecodeclub:dev Dec 25, 2023
4 checks passed
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.

2 participants