You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2021/09/26 11:46:44 UTC

[GitHub] [incubator-inlong] cxntsh commented on issue #1592: TextFileReader: The cpu utilization rate is very high, nearly 50%

cxntsh commented on issue #1592:
URL: https://github.com/apache/incubator-inlong/issues/1592#issuecomment-927291533


   I took a look at the source code, the while loop inside, there is empty polling for reading, which takes up too much CPU clock, can it be optimized?
   
   I try this code: 
   
   `@Override
       public Message read() {
           if (iterator != null && iterator.hasNext()) {
               String message = iterator.next();
               if (validateMessage(message)) {
                   textFileMetric.readNum.incr();
                   return new DefaultMessage(message.getBytes(StandardCharsets.UTF_8));
               }
           }
           AgentUtils.silenceSleepInMs(100); // This seems to work, is there a better way ??
           return null;
       }`


-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org