Add resizable write/search queue to OpenSearch#826
Add resizable write/search queue to OpenSearch#826rguo-aws wants to merge 2 commits intoopensearch-project:mainfrom
Conversation
Signed-off-by: Ruizhen <ruizhen@amazon.com>
|
✅ DCO Check Passed 507b3c7 |
|
✅ Gradle Wrapper Validation success 507b3c7 |
|
✅ Gradle Precommit success 507b3c7 |
|
start gradle check |
|
I think the commit message should have a bit more content describing what was done, I have seen quite a few commits to |
| // 5.x doesn't know about the "fixed_auto_queue_size" thread pool type, just write fixed. | ||
| out.writeString(ThreadPoolType.FIXED.getType()); | ||
| } else if (type == ThreadPoolType.RESIZABLE) { | ||
| // old vfi doesn't know about "resizable" thread pool. Convert RESIZABLE to FIXED |
There was a problem hiding this comment.
Can you please use the full term instead of the acronym vfi? acronyms are sometimes a burden for developers to feel comfortable with the project, especially when they are in a comment.
There was a problem hiding this comment.
Thanks for pointing this out, I rephrased my comments and removed "vfi" from it
| //TODO: The executor of our new SiFi resizable search queue is OpenSearchThreadPoolExecutor which | ||
| // unfortunately does not keep track of queueSize/EWMA execution time. We should ideally Add EWMA enabled threadpool | ||
| // executor and reenable the below unit test | ||
| // EWMATrackingEsThreadPoolExecutor from ES 8.0 and re-enable the below unit test. |
There was a problem hiding this comment.
I don't think anything should be taken from ES 8.0 as it is not Apache License Version 2.0.
I would definitely rephrase this comment and refrain from writing things that would lead anyone to believe (wrongfully) that the code is "from" anywhere but your own original design 😬
There was a problem hiding this comment.
Sorry for the confusion. We do not have intent to port code from ES 8.0. It was an error in comments and I've already cleared it up
| public static OpenSearchThreadPoolExecutor newResizable(String name, int size, int queueCapacity, | ||
| ThreadFactory threadFactory, ThreadContext contextHolder) { | ||
| BlockingQueue<Runnable> queue; | ||
| if (queueCapacity < 0) { |
There was a problem hiding this comment.
does it make any sense to be ok with a queue size of 0?
There was a problem hiding this comment.
yes, Queue size can be set to -1 to make it unbounded. This is to handle the case where queue size is -1 in opensearch.yml
There was a problem hiding this comment.
I am asking specifically about 0 though. I get the need for a -1 (although a bit confusing) as a flag for unbounded. I am asking to understand more than any form of critique of course:)
| if (queueCapacity < 0) { | ||
| queue = ConcurrentCollections.newBlockingQueue(); | ||
| } else { | ||
| queue = new SifiResizableBlockingQueue<>(ConcurrentCollections.<Runnable>newBlockingQueue(), |
There was a problem hiding this comment.
| queue = new SifiResizableBlockingQueue<>(ConcurrentCollections.<Runnable>newBlockingQueue(), | |
| queue = new OpenSearchResizableBlockingQueue<>(ConcurrentCollections.<Runnable>newBlockingQueue(), |
There was a problem hiding this comment.
thanks. made the changed as per your suggestion
| map.put(Names.ANALYZE, ThreadPoolType.FIXED); | ||
| map.put(Names.WRITE, ThreadPoolType.FIXED); | ||
| map.put(Names.SEARCH, ThreadPoolType.FIXED_AUTO_QUEUE_SIZE); | ||
| map.put(Names.WRITE, ThreadPoolType.RESIZABLE); |
There was a problem hiding this comment.
Do we really need to change WRITE threadpool as they have been moved to support byte-size based defaulting to 10k
There was a problem hiding this comment.
that is a very good point. yes, there is actually no need to change write to resizable anymore
| // Note: Disable this, since search pool has been changed to be of type RESIZABLE, which does not support a | ||
| // min_queue_size setting. | ||
| /* | ||
| if (rarely()) { | ||
| // Sometimes adjust the minimum search thread pool size, causing | ||
| // QueueResizingOpenSearchThreadPoolExecutor to be used instead of a regular | ||
| // fixed thread pool | ||
| builder.put("thread_pool.search.min_queue_size", 100); | ||
| } | ||
| */ |
There was a problem hiding this comment.
Remove rather than comment
| * Mainly makes sense to use with blocking queues that are unbounded to provide the ability to do | ||
| * capacity verification. | ||
| */ | ||
| public class SifiResizableBlockingQueue<E> extends SizeBlockingQueue<E> { |
Signed-off-by: Ruizhen <ruizhen@amazon.com>
|
✅ DCO Check Passed 96352ea |
|
✅ Gradle Wrapper Validation success 96352ea |
|
✅ Gradle Precommit success 96352ea |
|
✅ DCO Check Passed 96352ea |
|
✅ Gradle Wrapper Validation success 96352ea |
|
✅ Gradle Precommit success 96352ea |
| * Mainly makes sense to use with blocking queues that are unbounded to provide the ability to do | ||
| * capacity verification. | ||
| */ | ||
| public class OpenSearchResizableBlockingQueue<E> extends SizeBlockingQueue<E> { |
There was a problem hiding this comment.
What are the reasons to introduce this class instead of using the existing ResizableBlockingQueue ?
|
|
||
| private final BlockingQueue<E> queue; | ||
| private final int capacity; | ||
| protected volatile int capacity; |
There was a problem hiding this comment.
I think this change should not be taken lightly: the truly fixed size queues (SizeBlockingQueue) would have to pay a price of accessing the volatile field which is only adjustable for resizeable queues.
|
Can one of the admins verify this patch? |
|
@rguo-aws are you working on this? there are couple of comments need to be addressed. |
|
✅ Gradle Wrapper Validation success 96352ea |
|
✅ DCO Check Passed 96352ea |
|
✅ Gradle Precommit success 96352ea |
|
@AmiStrn or @reta any interest in picking this up from where @rguo-aws left it at? |
|
Thanks @dblock but Im not available for this in this quarter, so I kindly decline. |
|
@dblock I am in, will take a look shortly |
|
Hey @reta ! Are you still thinking about this one? Thanks! |
|
@CEHENKLE yes! I will pick up shortly, thanks for reminding ! |
|
@reta Cool beans -- thanks! :) |
|
@CEHENKLE continuing the work in https://github.com/opensearch-project/OpenSearch/pull/3207/files since I cannot push changes to the original branch. |
|
Closing in favor of #3207 |
* Make search/write queue resizable Signed-off-by: Ruizhen <ruizhen@amazon.com> * Address PR comments Signed-off-by: Ruizhen <ruizhen@amazon.com> * Refactoring resizable queue implementation Signed-off-by: Andriy Redko <andriy.redko@aiven.io> * Addressing code review comments Signed-off-by: Andriy Redko <andriy.redko@aiven.io> * Addressing code review comments Signed-off-by: Andriy Redko <andriy.redko@aiven.io> * Addressing code review comments Signed-off-by: Andriy Redko <andriy.redko@aiven.io> Co-authored-by: Ruizhen <ruizhen@amazon.com>
Signed-off-by: Ruizhen ruizhen@amazon.com
Description
Create a new type of threadpool queue "OpenSearchResizableBlockingQueue" to dynamically adjust search queue size in runtime.
The current threadpool queue for search is of "FIXED" type and the queue capacity can only be updated via opensearch.yml.
This OpenSearchResizableBlockingQueue that is introduced in this PR can allow us to make changes to queue size without restarting OpsearchSearch process.
Also addressed unit test failures in this PR
Issues Resolved
#476
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.