weijietong commented on a change in pull request #2000: DRILL-7607: support dynamic credit based flow control URL: https://github.com/apache/drill/pull/2000#discussion_r386007077
########## File path: exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/UnlimitedRawBatchBuffer.java ########## @@ -90,14 +100,39 @@ public boolean isEmpty() { @Override public void add(RawFragmentBatch batch) { + int recordCount = batch.getHeader().getDef().getRecordCount(); + long bathByteSize = batch.getByteCount(); + if (recordCount != 0) { + //skip first header batch + totalBatchSize += bathByteSize; + sampleTimes++; + } + if (sampleTimes == maxSampleTimes) { + long averageBathSize = totalBatchSize / sampleTimes; + //make a decision + long limit = context.getAllocator().getLimit(); + long thresholdNetworkMem = (long) (limit * 0.40); + if (averageBathSize > 0) { + runtimeSoftLimit = (int) (thresholdNetworkMem / averageBathSize); + runtimeAckCredit = runtimeSoftLimit / fragmentCount; + runtimeAckCredit = runtimeAckCredit > 0 ? runtimeAckCredit : 1; + } + } + if (runtimeSoftLimit > 0) { Review comment: If we get a 0 runtimeSoftLimit, we do nothing just to keep the original static credit flow control. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services