You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/08/18 07:22:54 UTC
[GitHub] [flink] reswqa commented on a diff in pull request #20553: [FLINK-28800][network] HsFileDataManager should avoid busy-loop when fileReader has not data to read
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org