-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix] [broker] consider iowait as idle. #19110
[fix] [broker] consider iowait as idle. #19110
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, can we add a unit test for this?
@mattisonchao Will this issue be resolved with the oshi library? |
done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
@@ -132,7 +133,7 @@ public static ResourceUsage getCpuUsageForEntireHost() { | |||
.filter(s -> !s.contains("cpu")) | |||
.mapToLong(Long::parseLong) | |||
.sum(); | |||
long idle = Long.parseLong(words[4]); | |||
long idle = Long.parseLong(words[4]) + Long.parseLong(words[5]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be a little dangerous to split values directly, can it be handled by oshi library?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we consider using oshi
library, may be we should rewrite whole module using oshi
?
oshi
support for retrieving system information, such as memory and CPU usage, disks and partitions, etc.
To fix the iowait
problem, a simple patch above may be a better solution.
@mattisonchao
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current implementation of module is splitting values directly.
long idle = Long.parseLong(words[4]);
there is no different with the patch.
long idle = Long.parseLong(words[4]) + Long.parseLong(words[5]);
I think we could fix this problem with this patch first.
WDYT. @codelipenghui
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/pulsarbot rerun-failure-checks |
Codecov Report
@@ Coverage Diff @@
## master #19110 +/- ##
============================================
- Coverage 45.63% 36.22% -9.42%
+ Complexity 11013 7906 -3107
============================================
Files 772 712 -60
Lines 74313 69598 -4715
Branches 7998 7470 -528
============================================
- Hits 33915 25211 -8704
- Misses 36604 41058 +4454
+ Partials 3794 3329 -465
Flags with carried forward coverage won't be shown. Click here to find out more.
|
The pr had no activity for 30 days, mark with Stale label. |
# Conflicts: # pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LinuxInfoUtils.java # pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LinuxBrokerHostUsageImpl.java
Fixes #19109 #19109
Motivation
CPU usage calculated in pulsar is implemented by reading
/proc/stat
, that is sum all cpu time and substract idle time.But real CPU usage should equal the sum substracting the idle cycles (idle+iowait), because
%iowait
represents the percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request.https://www.ibm.com/docs/en/linux-on-systems?topic=tests-understanding-cpu-utilization
Modifications
consider iowait as idle.
Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: thetumbled#11