Skip to content
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

[Bug] incorrect CPU usage collected by pulsar #17815

Closed
2 tasks done
thetumbled opened this issue Sep 23, 2022 · 5 comments
Closed
2 tasks done

[Bug] incorrect CPU usage collected by pulsar #17815

thetumbled opened this issue Sep 23, 2022 · 5 comments
Assignees
Labels
Stale type/bug The PR fixed a bug or issue reported a bug

Comments

@thetumbled
Copy link
Member

Search before asking

  • I searched in the issues and found nothing similar.

Version

pulsar 2.9.3
linux 4.19.16

Minimal reproduce step

  1. enable CGROUP
  2. assign 23 CPUs to broker process,while there are 40 CPUs in the system
    taskset fffffe0000 bin/***

What did you expect to see?

  1. cpu usage is smaller than 100%

What did you see instead?

  1. cpu usage is greater than 100%,and the cpu usage reported by pulsar need to be fixed by multiply 23/40.
  2. for example,pulsar could report 150%,but the real cpu usage is 150*23/40=86.25%

Anything else?

this is because Runtime.getRuntime().availableProcessors() method return 23, which is the number of processors can be utilized by this process, but what we need is 40.
we could retrieve metadata from ZK, and verify that the limit of cpu is 2300, not 4000.
image

Are you willing to submit a PR?

  • I'm willing to submit a PR!
@thetumbled thetumbled added the type/bug The PR fixed a bug or issue reported a bug label Sep 23, 2022
thetumbled pushed a commit to thetumbled/pulsar that referenced this issue Sep 23, 2022
taskset broker to some CPUs in the system
[Bug] incorrect CPU usage collected by pulsar apache#17815
Minimal reproduce step
enable CGROUP
assign 23 CPUs to broker process,while there are 40 CPUs in the system
taskset fffffe0000 bin/***
What did you expect to see?
cpu usage is smaller than 100%
What did you see instead?
cpu usage is greater than 100%,and the cpu usage reported by pulsar need to be fixed by multiply 23/40.
for example,pulsar could report 150%,but the real cpu usage is 150*23/40=86.25%
thetumbled pushed a commit to thetumbled/pulsar that referenced this issue Sep 23, 2022
@mattisonchao
Copy link
Member

Thanks for your contribution!

@lhotari
Copy link
Member

lhotari commented Oct 5, 2022

this is because Runtime.getRuntime().availableProcessors() method return 23, which is the number of processors can be utilized by this process, but what we need is 40.

One workaround for the above issue is to add JVM option -XX:ActiveProcessorCount=n where n=the total available CPU cores. In the example case, adding -XX:ActiveProcessorCount=n to Pulsar's JVM options would be a workaround.

@thetumbled
Copy link
Member Author

actually,we restrict pulsar broker to use 23 CPU cores on purpose. i wonder whether there are any problem to set a dummy value 40.

This HotSpot option is recognized by OpenJ9 for compatibility. Use this option to override the number of CPUs that the VM automatically detects and uses when creating threads for various subsystems.
https://www.eclipse.org/openj9/docs/xxactiveprocessorcount/

@github-actions
Copy link

github-actions bot commented Nov 6, 2022

The issue had no activity for 30 days, mark with Stale label.

@github-actions github-actions bot added the Stale label Nov 6, 2022
@lhotari
Copy link
Member

lhotari commented Oct 14, 2024

Addressed by #16832

@lhotari lhotari closed this as completed Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants