reswqa commented on code in PR #20553:
URL: https://github.com/apache/flink/pull/20553#discussion_r948741464
##########
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/hybrid/HsFileDataManager.java:
##########
@@ -147,6 +148,17 @@ public void setup() {
// concurrent `run()` executions. Concurrent calls to other methods are
allowed.
public synchronized void run() {
int numBuffersRead = tryRead();
+ if (numBuffersRead == 0) {
+ try {
+ // When fileReader has no data to read, for example, most of
the data is consumed
+ // from memory. HsFileDataManager will encounter busy-loop
problem, which will lead
+ // to a meaningless surge in CPU utilization and seriously
affect performance. Sleep
+ // for a very short time to avoid this.
+ TimeUnit.MILLISECONDS.sleep(5);
+ } catch (InterruptedException exp) {
+ throw new RuntimeException("FileDataManager's sleep is
interrupted.", exp);
+ }
+ }
Review Comment:
Changed to use `ScheduledExecutorService` to avoid thread sleep.
--
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]