feat: add MemorySafeLinkedBlockingQueue#1213
feat: add MemorySafeLinkedBlockingQueue#1213Codeprh wants to merge 4 commits intosofastack:masterfrom
Conversation
|
Hi @Codeprh, welcome to SOFAStack community, Please sign Contributor License Agreement! After you signed CLA, we will automatically sync the status of this pull request in 3 minutes. |
|
Hi @Codeprh, thank for your PR. Please run |
done,3q |
Codecov Report
@@ Coverage Diff @@
## master #1213 +/- ##
============================================
+ Coverage 71.56% 72.09% +0.52%
+ Complexity 832 780 -52
============================================
Files 408 412 +4
Lines 17224 17403 +179
Branches 2684 2702 +18
============================================
+ Hits 12327 12546 +219
+ Misses 3533 3475 -58
- Partials 1364 1382 +18
Continue to review full report at Codecov.
|
|
|
||
| @Override | ||
| public void put(final E e) throws InterruptedException { | ||
| if (hasRemainedMemory()) { |
There was a problem hiding this comment.
I think it is important to notify users when they fail to put an element to the queue.
There was a problem hiding this comment.
Good idea. Maybe notify action should like java.util.concurrent.RejectedExecutionHandler.
core/common/src/main/java/com/alipay/sofa/rpc/common/threadpool/MemoryLimiter.java
Outdated
Show resolved
Hide resolved
| } else { | ||
| queue = size < 0 ? new LinkedBlockingQueue<Runnable>() | ||
| queue = size < 0 ? new MemorySafeLinkedBlockingQueue<Runnable>() | ||
| : new LinkedBlockingQueue<Runnable>(size); |
There was a problem hiding this comment.
shall be an ArrayBlockingQueue once size is set. LinkedBlockingQueue will not block/reject adding a new element when reaching threshold(input size).
But it's Ok not to fix this, as it is what it was.
core/common/src/main/java/com/alipay/sofa/rpc/common/threadpool/MemoryLimiter.java
Outdated
Show resolved
Hide resolved
|
also see : apache/dubbo#9789 |
|
@OrezzerO @Codeprh How about this PR: apache/shenyu#3764 ? |
This PR has better handling of exceptions. 👍 |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
review again |
|
Hello, I am a code review bot on flows.network. Here are my reviews of code commits in this PR. Overall summary: This pull request introduces the "feat: add MemorySafeLinkedBlockingQueue" feature, which involves the creation of the Potential issues:
Key findings:
Recommendations:
DetailsCommit b5fd13d458ba25ab08579a5b5149c0a1d80ea83fSummary of key changes:
Key findings and potential problems:
Commit 94e41ca93544c57a864a64a76277efb7914e595eThis pull request makes changes to 4 files related to the MemorySafeLinkedBlockingQueue implementation: Key changes:
Potential problems:
Commit 622ba0a251513b3d54a25ce31135fab09c21fc08This patch is for the file
Potential problems:
Commit ae2e21f554e0f7317c7c73eedfd245be769403b1Summary of key changes in the patch:
Potential problems:
Based on this patch, I recommend checking for any dependencies on the |


Motivation:
Can completely solve the OOM problem caused by {@link java.util.concurrent.LinkedBlockingQueue}
Modification and Result:
CN
参考dubbo的思想(dubbo-pr),引入MemorySafeLinkedBlockingQueue,解决无界队列可能会导致OOM的问题
EN
Referring to the idea of dubbo(dubbo-pr), introduce MemorySafeLinkedBlockingQueue to solve the problem that unbounded queues may cause OOM