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

analyze-build doesn’t honor cgroup CPU limitations if launched inside a container #57050

Open
dsilakov opened this issue Aug 10, 2022 · 3 comments

Comments

@dsilakov
Copy link

When launched without debug, analyze-build creates a pool of size None:

https://github.com/llvm/llvm-project/blob/main/clang/tools/scan-build-py/lib/libscanbuild/analyze.py#L238

In this case, python creates a pool of os.cpu_count() items. Unfortunately, cpu_count() doesn’t honor cgroup limitations – this is a known cpython issue (python/cpython#80235) and it doesn’t look like it will be fixed in the near future.

This provides significant server load if you launch analyzer inside a container on some powerful machine.

At the same time, pylint has developed its own implementation of cpu counter which is aware of cgroups: _query_cpu(), https://github.com/PyCQA/pylint/blob/main/pylint/lint/run.py#L34

It would be nice to take _query_cpu() from pylint (or provide a similar solution) and call it instead of using None in https://github.com/llvm/llvm-project/blob/main/clang/tools/scan-build-py/lib/libscanbuild/analyze.py#L238

@llvmbot
Copy link
Member

llvmbot commented Aug 10, 2022

@llvm/issue-subscribers-clang-static-analyzer

@steakhal
Copy link
Contributor

I rarely use scanbuild, but I think what you suggests makes sense. Put me on the review if you plan to propose a change.

@dsilakov
Copy link
Author

Ok. Though after some experiments _cpu_count() implementation in pylint turned out to be not ideal and can work incorrectly on a real hardware - see pylint-dev/pylint#7338. So currently I use its truncated variant without a hack for AWS. Will monitor how it works and create a PR if everything is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants