elek commented on pull request #1644:
URL: https://github.com/apache/ozone/pull/1644#issuecomment-737127305


   > @elek Please correct me if I am wrong. If the queue is not full, it means 
we do not have too many tasks, then we do not need to create new thread, so 
maybe dynamic thread pool is also appropriate ?
   
   Let's say we have 5 replication tasks scheduled. I would prefer to have 5 
threads to work on it. But the current queue is unbounded, it's never full:
   
   
![image](https://user-images.githubusercontent.com/170549/100857984-a9e01480-348d-11eb-942e-1c39d4fcf3e8.png)
   
   With the current code, we will have on thread all the time as we have 
unlimited space in the queue: Java doesn't panic.
   
   An alternative approach is to use a bounded queue (`new 
LinkedBlockingQueue(10)`) but in this case the scheduling can be blocked (if 
SCM sends requests to replicate 100 containers, the scheduling will be blocked 
after the first 10 is added to the queue) which cause other problems on the RPC 
side.
   
   For me it was not intuitive (threads are not scaled up unless the queue is 
full), but this seems to be the normal behavior of `ThreadPool`


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to