guihecheng commented on a change in pull request #3168:
URL: https://github.com/apache/ozone/pull/3168#discussion_r823706683



##########
File path: 
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java
##########
@@ -1733,10 +1733,11 @@ public ExecutorService getECReconstructExecutor() {
           ecReconstructExecutor = new ThreadPoolExecutor(
               EC_RECONSTRUCT_STRIPE_READ_POOL_MIN_SIZE,
               clientConfig.getEcReconstructStripeReadPoolLimit(),
-              60, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),
+              60, TimeUnit.SECONDS, new SynchronousQueue<>(),

Review comment:
       Oh, here my aim is to do not let reconstruct reader threads wait in a 
queue for long, so I adopted this aggressive `SynchronousQueue`.
   Only when max size of the thread pool is reached, we will get a 
`RejectedExecutionException`, and the current work will be handled in the 
caller thread *automatically* with the policy `CallerRunsPolicy` configured.
   Actually I borrow this idea from HDFS, 
FYI:https://github.com/apache/hadoop/blob/9539ff108aaa420168935a3dbc73c43c1686e252/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java#L3115
   
   So let's say that we use a `LinkedBlockingQueue` here with capacity 1024(I'm 
not sure how to pick a sensible queue limit here), then the thread pool will 
stay with the core pool size until the queue is full with 1024 works, but 
sometimes the pool is too small for parallelism:
   If we configured EC 10+4, 4 DNs down, then reconstruct, under normal 
loads(say 10 concurrent reconstruct read of 10 4G files), we will have number 
of the core pool size threads(now it is set to 3, see code comments and we 
could discuss about this value too) to handle the stripe read work before we 
could decode.
   So the concurrent thread number seems not enough to read all available 
chunks parallelly, but the queue is not filled and no new threads will come to 
help.
   Of course we could set the core pool size default to 10, then we are fine 
with the above case, but we'll have 10 threads pinned in the client.
   
   So I prefer to use `SynchronousQueue` + `CallerRunsPolicy`, then:
   1. initially we'll have less pinned threads
   2. the thread pool grows sensitively with the load(since `SynchronousQueue` 
actually never queue anything), thus normal loads benefits.
   3. At last, if we have extreme reconstruct read loads, `CallerRunsPolicy` 
will let rejected works have a chance to retry in the caller thread.




-- 
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.

To unsubscribe, e-mail: [email protected]

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